/srv/mercurial-server/detachablepurple: 1914b2dfa263: Turned the...

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


Changeset: 1914b2dfa2632a77f9ff296041a5071a2df0e024
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-20 15:58 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/1914b2dfa263

Description:

Turned the PurpleBlistNode struct fields into GObject properties,
so that we can export them on D-Bus. I did not commit this to the
gobjectification branch because I think such a think would be
overkill, we only need it here for detachable sessions'sake.

diffstat:

 libpurple/blist-node.c |  97 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 97 insertions(+), 0 deletions(-)

diffs (114 lines):

diff --git a/libpurple/blist-node.c b/libpurple/blist-node.c
--- a/libpurple/blist-node.c
+++ b/libpurple/blist-node.c
@@ -690,6 +690,75 @@
 
 static GObjectClass *parent_class = NULL;
 
+/* GObject Property enums */
+enum
+{
+	PROP_0,
+	PROP_PREV,
+	PROP_NEXT,
+	PROP_PARENT,
+	PROP_CHILD,
+	PROP_LAST
+};
+
+/* GObject Property names */
+#define PROP_PREV_S       "prev"
+#define PROP_NEXT_S       "next"
+#define PROP_PARENT_S     "parent"
+#define PROP_CHILD_S      "child"
+
+/* Set method for GObject properties */
+static void
+purple_blist_node_set_property(GObject *obj, guint param_id,
+                               const GValue *value, GParamSpec *pspec)
+{
+	PurpleBlistNode *node = PURPLE_BLIST_NODE(obj);
+
+	switch (param_id) {
+		case PROP_PREV:
+			node->prev = g_value_get_object(value);
+			break;
+		case PROP_NEXT:
+			node->next = g_value_get_object(value);
+			break;
+		case PROP_PARENT:
+			node->parent = g_value_get_object(value);
+			break;
+		case PROP_CHILD:
+			node->child = 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_node_get_property(GObject *obj, guint param_id,
+                               GValue *value, GParamSpec *pspec)
+{
+	PurpleBlistNode *node = PURPLE_BLIST_NODE(obj);
+
+	switch (param_id) {
+		case PROP_PREV:
+			g_value_set_object(value, node->prev);
+			break;
+		case PROP_NEXT:
+			g_value_set_object(value, node->next);
+			break;
+		case PROP_PARENT:
+			g_value_set_object(value, node->parent);
+			break;
+		case PROP_CHILD:
+			g_value_set_object(value, node->child);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
 static void
 purple_blist_node_finalize(GObject *object)
 {
@@ -743,6 +812,34 @@
 	klass->prev = purple_blist_node_real_prev;
 	klass->is_online = NULL;
 
+	/* Setup properties */
+	obj_class->get_property = purple_blist_node_get_property;
+	obj_class->set_property = purple_blist_node_set_property;
+
+	g_object_class_install_property(obj_class, PROP_PREV,
+	        g_param_spec_object(PROP_PREV_S, _("Previous"),
+	            _("The previous node."), PURPLE_TYPE_BLIST_NODE,
+	            G_PARAM_READWRITE)
+	        );
+
+	g_object_class_install_property(obj_class, PROP_NEXT,
+	        g_param_spec_object(PROP_NEXT_S, _("Next"),
+	            _("The next node."), PURPLE_TYPE_BLIST_NODE,
+	            G_PARAM_READWRITE)
+	        );
+
+	g_object_class_install_property(obj_class, PROP_PARENT,
+	        g_param_spec_object(PROP_PARENT_S, _("Parent"),
+	            _("The parent node."), PURPLE_TYPE_BLIST_NODE,
+	            G_PARAM_READWRITE)
+	        );
+
+	g_object_class_install_property(obj_class, PROP_CHILD,
+	        g_param_spec_object(PROP_CHILD_S, _("Child"),
+	            _("The child node."), PURPLE_TYPE_BLIST_NODE,
+	            G_PARAM_READWRITE)
+	        );
+
 #if 0
 	purple_signal_register( purple_blist_node_handle(),
 													"node-removed",



More information about the Commits mailing list