gobjectification: d89369c8: Add a few signals to blist-nodes.

sadrul at pidgin.im sadrul at pidgin.im
Tue Jul 6 17:20:27 EDT 2010


----------------------------------------------------------------------
Revision: d89369c8e21a5db6efd61e7ddbdf5b3b60c86866
Parent:   71d3b7f34561315f66042276a9b97c62893d0580
Author:   sadrul at pidgin.im
Date:     07/06/10 13:54:56
Branch:   im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/d89369c8e21a5db6efd61e7ddbdf5b3b60c86866

Changelog: 

Add a few signals to blist-nodes.

Changes against parent 71d3b7f34561315f66042276a9b97c62893d0580

  patched  libpurple/blist-node.c
  patched  libpurple/marshallers.list

-------------- next part --------------
============================================================
--- libpurple/marshallers.list	5070bd1441d6e10de7267872fbdea4e539797b3f
+++ libpurple/marshallers.list	c5a4cd7ed04de076d46c5bdc1484ae828e1c11bc
@@ -1,4 +1,5 @@ VOID:OBJECT
 VOID:OBJECT
+VOID:OBJECT,OBJECT
 VOID:POINTER
 VOID:POINTER,POINTER
 VOID:POINTER,POINTER,OBJECT
============================================================
--- libpurple/blist-node.c	957871edfc3bedb17d390ab45c4c5f6d6d22e376
+++ libpurple/blist-node.c	3ea27dac196d63d8d423ec1b9f89a04410afb92a
@@ -29,7 +29,19 @@
 #include "server.h"
 #include "signals.h"
 #include "xmlnode.h"
+#include "marshallers.h"
 
+enum
+{
+	SIG_UPDATED,
+	SIG_CHILD_UPDATED,
+	SIG_CHILD_ADDED,
+	SIG_CHILD_REMOVED,
+	SIG_PARENT_SET,
+	SIG_LAST
+};
+static guint signals[SIG_LAST] = { 0 };
+
 struct _PurpleBlistNodePrivate {
 	GHashTable *settings;                 /**< per-node settings; keys are
 	                                           <tt>gchar *</tt>, values are
@@ -58,7 +70,7 @@ purple_blist_get_last_child(PurpleBlistN
 		return NULL;
 	return purple_blist_get_last_sibling(node->child);
 }
-  
+
 void
 parse_setting(PurpleBlistNode *node, xmlnode *setting)
 {
@@ -464,25 +476,46 @@ purple_blist_node_real_add_child(PurpleB
 static void
 purple_blist_node_real_add_child(PurpleBlistNode *parent, PurpleBlistNode *child)
 {
+	PurpleBlistNode *oldp = child->parent;
+
+	if (oldp == parent)
+		return;
+
 	if (parent->child)
 		parent->child->prev = child;
 	child->prev = NULL;
 	child->next = parent->child;
 	parent->child = child;
 	child->parent = parent;
+
+	g_signal_emit(G_OBJECT(parent), signals[SIG_CHILD_ADDED], 0, child);
+	g_signal_emit(G_OBJECT(child), signals[SIG_PARENT_SET], 0, parent, oldp);
+	if (oldp)
+		g_signal_emit(G_OBJECT(oldp), signals[SIG_CHILD_REMOVED], 0, child);
 }
 
 static void
 purple_blist_node_real_add_sibling(PurpleBlistNode *node, PurpleBlistNode *sibling)
 {
+	PurpleBlistNode *oldp;
+
 	g_return_if_fail(node);
 	g_return_if_fail(sibling);
 
+	oldp = sibling;
+
 	sibling->parent = node->parent;
 	sibling->prev = node;
 	if ((sibling->next = node->next))
 		node->next->prev = sibling;
 	node->next = sibling;
+
+	if (node->parent)
+		g_signal_emit(G_OBJECT(node->parent), signals[SIG_CHILD_ADDED], 0, sibling);
+	if (oldp)
+		g_signal_emit(G_OBJECT(oldp), signals[SIG_CHILD_REMOVED], 0, sibling);
+	if (oldp != node->parent)
+		g_signal_emit(G_OBJECT(sibling), signals[SIG_PARENT_SET], 0, node->parent, oldp);
 }
 
 
@@ -706,6 +739,7 @@ purple_blist_node_class_init(PurpleBlist
 	klass->prev = purple_blist_node_real_prev;
 	klass->is_online = NULL;
 
+#if 0
 	purple_signal_register( purple_blist_node_handle(),
 													"node-removed",
 													purple_marshal_VOID__POINTER,
@@ -726,8 +760,38 @@ purple_blist_node_class_init(PurpleBlist
 													NULL,
 													1,
 													purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_BLIST_NODE));
+#endif
 
+	/* This should be emitted when something changes in a node. */
+	signals[SIG_UPDATED] = g_signal_new("updated", G_OBJECT_CLASS_TYPE(klass),
+			G_SIGNAL_ACTION, 0, NULL, NULL,
+			g_cclosure_marshal_VOID__VOID,
+			G_TYPE_NONE, 0);
 
+	/* This should be emitted when something changes in a child node. */
+	signals[SIG_CHILD_UPDATED] = g_signal_new("child-updated", G_OBJECT_CLASS_TYPE(klass),
+			G_SIGNAL_ACTION, 0, NULL, NULL,
+			g_cclosure_marshal_VOID__OBJECT,
+			G_TYPE_NONE,
+			1, PURPLE_BLIST_NODE_TYPE);		/* The child that updated */
+
+	signals[SIG_CHILD_ADDED] = g_signal_new("child-added", G_OBJECT_CLASS_TYPE(klass),
+			G_SIGNAL_ACTION, 0, NULL, NULL,
+			g_cclosure_marshal_VOID__OBJECT,
+			G_TYPE_NONE,
+			1, PURPLE_BLIST_NODE_TYPE);		/* The child added */
+
+	signals[SIG_CHILD_REMOVED] = g_signal_new("child-removed", G_OBJECT_CLASS_TYPE(klass),
+			G_SIGNAL_ACTION, 0, NULL, NULL,
+			g_cclosure_marshal_VOID__OBJECT,
+			G_TYPE_NONE,
+			1, PURPLE_BLIST_NODE_TYPE);		/* The child removed */
+
+	signals[SIG_PARENT_SET] = g_signal_new("parent-set", G_OBJECT_CLASS_TYPE(klass),
+			G_SIGNAL_ACTION, 0, NULL, NULL,
+			purple_smarshal_VOID__OBJECT_OBJECT,
+			G_TYPE_NONE,
+			2, PURPLE_BLIST_NODE_TYPE, PURPLE_BLIST_NODE_TYPE);	/* New parent, Old parent */
 }
 
 static void


More information about the Commits mailing list