/soc/2013/ankitkv/gobjectification: 07f8ceb4e690: Added GBoxed f...

Ankit Vani a at nevitus.org
Tue Jul 16 11:37:19 EDT 2013


Changeset: 07f8ceb4e690436619114fbef03832c89bb87f82
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-16 20:57 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/07f8ceb4e690

Description:

Added GBoxed for PurpleNotifyUserInfo

diffstat:

 libpurple/notify.c |  36 ++++++++++++++++++++++++++++++++++++
 libpurple/notify.h |   8 ++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diffs (72 lines):

diff --git a/libpurple/notify.c b/libpurple/notify.c
--- a/libpurple/notify.c
+++ b/libpurple/notify.c
@@ -692,6 +692,42 @@ purple_notify_user_info_remove_last_item
 		purple_notify_user_info_entry_destroy(entry);
 }
 
+static PurpleNotifyUserInfo *
+purple_notify_user_info_copy(PurpleNotifyUserInfo *user_info)
+{
+	PurpleNotifyUserInfo *user_info_copy;
+	GList *l;
+
+	g_return_val_if_fail(user_info != NULL, NULL);
+
+	user_info_copy = purple_notify_user_info_new();
+
+	for (l = user_info->entries.head; l != NULL; l = l->next) {
+		PurpleNotifyUserInfoEntry *new_entry, *user_info_entry = l->data;
+
+		new_entry = purple_notify_user_info_entry_new(user_info_entry->label,
+				user_info_entry->value);
+		new_entry->type = user_info_entry->type;
+		g_queue_push_tail(&user_info_copy->entries, new_entry);
+	}
+
+	return user_info_copy;
+}
+
+GType
+purple_notify_user_info_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PurpleNotifyUserInfo",
+				(GBoxedCopyFunc)purple_notify_user_info_copy,
+				(GBoxedFreeFunc)purple_notify_user_info_destroy);
+	}
+
+	return type;
+}
+
 void *
 purple_notify_uri(void *handle, const char *uri)
 {
diff --git a/libpurple/notify.h b/libpurple/notify.h
--- a/libpurple/notify.h
+++ b/libpurple/notify.h
@@ -32,7 +32,10 @@
 #include <glib.h>
 
 typedef struct _PurpleNotifyUserInfoEntry	PurpleNotifyUserInfoEntry;
+
+#define  PURPLE_TYPE_NOTIFY_USER_INFO  (purple_notify_user_info_get_type())
 typedef struct _PurpleNotifyUserInfo		PurpleNotifyUserInfo;
+
 /** @copydoc _PurpleNotifySearchColumn */
 typedef struct _PurpleNotifySearchColumn	PurpleNotifySearchColumn;
 
@@ -422,6 +425,11 @@ void *purple_notify_userinfo(PurpleConne
 						   gpointer user_data);
 
 /**
+ * Returns the GType for the PurpleNotifyUserInfo boxed structure.
+ */
+GType purple_notify_user_info_get_type(void);
+
+/**
  * Create a new PurpleNotifyUserInfo which is suitable for passing to
  * purple_notify_userinfo()
  *



More information about the Commits mailing list