/srv/mercurial-server/detachablepurple: 2112512b7d20: Turned the...

Gilles Bedel gillux at cpw.pidgin.im
Fri Jun 15 22:01:45 EDT 2012


Changeset: 2112512b7d20b03f34e8ffee62fd38bf5eb3efe0
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-20 16:19 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/2112512b7d20

Description:

Turned the "root" field of the PurpleBuddyList into a GObject property.
This gobjectification is only for detachable sessions'sake, as the
PurpleBuddyList type's scope is limited to blist.c.

diffstat:

 libpurple/blist.c |  58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 2 deletions(-)

diffs (90 lines):

diff --git a/libpurple/blist.c b/libpurple/blist.c
--- a/libpurple/blist.c
+++ b/libpurple/blist.c
@@ -1353,6 +1353,49 @@
 /*  GObject Code  */
 /******************/
 
+/* GObject Property enums */
+enum
+{
+        PROP_0,
+	PROP_ROOT,
+	PROP_LAST
+};
+
+/* GObject Property names */
+#define PROP_ROOT_S       "root"
+
+/* Set method for GObject properties */
+static void
+purple_blist_set_property(GObject *obj, guint param_id, const GValue *value,
+                          GParamSpec *pspec)
+{
+	PurpleBuddyList *blist = PURPLE_BUDDY_LIST(obj);
+	switch (param_id) {
+		case PROP_ROOT:
+                        blist->node = g_value_get_object(value);
+                        break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
+/* Get method for GObject properties */
+static void
+purple_blist_get_property(GObject *obj, guint param_id, GValue *value,
+                          GParamSpec *pspec)
+{
+	PurpleBuddyList *blist = PURPLE_BUDDY_LIST(obj);
+	switch (param_id) {
+		case PROP_ROOT:
+                        g_value_set_object(value, blist->node);
+                        break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
 static void
 purple_blist_finalize(GObject *object)
 {
@@ -1370,9 +1413,10 @@
 new_group_added(PurpleGroup *group, gpointer null)
 {
 	PurpleBuddyList *list = PURPLE_BLIST;
-	if (list->node == NULL)
+	if (list->node == NULL) {
 		list->node = PURPLE_BLIST_NODE(group);
-	else {
+		g_object_notify(G_OBJECT(list), PROP_ROOT_S);
+	} else {
 		PurpleBlistNode *node = list->node, *next;
 		while ((next = purple_blist_node_next(node)))
 			node = next;
@@ -1390,6 +1434,7 @@
 	if (list->node == PURPLE_BLIST_NODE(group))
 		list->node = purple_blist_node_next(PURPLE_BLIST_NODE(group));
 	g_hash_table_remove(list->groups_cache, purple_group_get_name(group));
+	g_object_notify(G_OBJECT(list), PROP_ROOT_S);
 }
 
 static void
@@ -1429,6 +1474,15 @@
 	parent_class = g_type_class_peek_parent(klass);
 	obj_class->finalize = purple_blist_finalize;
 
+	obj_class->get_property = purple_blist_get_property;
+	obj_class->set_property = purple_blist_set_property;
+
+	g_object_class_install_property(obj_class, PROP_ROOT,
+	              g_param_spec_object(PROP_ROOT_S, _("Root"),
+	                              _("The root node for the buddy list."),
+	                              PURPLE_TYPE_BUDDY_LIST, G_PARAM_READWRITE)
+	              );
+
 	purple_signal_register(handle, "buddy-status-changed",
 	                     purple_marshal_VOID__POINTER_POINTER_POINTER, NULL,
 	                     3,



More information about the Commits mailing list