/pidgin/main: 49ac171ebe26: move CountingNode to it's own file

Gary Kramlich <[email protected]> Thu, 25 Aug 2016 23:54:12 -0400
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 49ac171ebe26df8130de409338ebecb32d89a792
Author:	 Gary Kramlich <[email protected]>
Date:	 2016-08-12 16:52 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/49ac171ebe26

Description:

move CountingNode to it's own file

diffstat:

 libpurple/Makefile.am    |    2 +
 libpurple/blistnode.c    |  238 ------------------------------------------
 libpurple/blistnode.h    |  163 +----------------------------
 libpurple/countingnode.c |  265 +++++++++++++++++++++++++++++++++++++++++++++++
 libpurple/countingnode.h |  184 ++++++++++++++++++++++++++++++++
 libpurple/group.h        |    2 +-
 6 files changed, 456 insertions(+), 398 deletions(-)

diffs (truncated from 947 to 300 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -61,6 +61,7 @@ purple_coresources = \
 	conversationtypes.c \
 	conversations.c \
 	core.c \
+	countingnode.c \
 	debug.c \
 	e2ee.c \
 	eventloop.c \
@@ -146,6 +147,7 @@ purple_coreheaders = \
 	conversationtypes.h \
 	conversations.h \
 	core.h \
+	countingnode.h \
 	dbus-maybe.h \
 	debug.h \
 	e2ee.h \
diff --git a/libpurple/blistnode.c b/libpurple/blistnode.c
--- a/libpurple/blistnode.c
+++ b/libpurple/blistnode.c
@@ -29,11 +29,6 @@
 
 typedef struct _PurpleBlistNodePrivate  PurpleBlistNodePrivate;
 
-#define PURPLE_COUNTING_NODE_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_COUNTING_NODE, PurpleCountingNodePrivate))
-
-typedef struct _PurpleCountingNodePrivate  PurpleCountingNodePrivate;
-
 /* Private data of a buddy list node */
 struct _PurpleBlistNodePrivate {
 	GHashTable *settings;  /* per-node settings                            */
@@ -48,29 +43,9 @@ enum
 	BLNODE_PROP_LAST
 };
 
-/* Private data of a counting node */
-struct _PurpleCountingNodePrivate {
-	int totalsize;    /* The number of children under this node            */
-	int currentsize;  /* The number of children under this node
-	                     corresponding to online accounts                  */
-	int onlinecount;  /* The number of children under this contact who are
-	                     currently online                                  */
-};
-
-/* Counting node property enums */
-enum
-{
-	CNODE_PROP_0,
-	CNODE_PROP_TOTAL_SIZE,
-	CNODE_PROP_CURRENT_SIZE,
-	CNODE_PROP_ONLINE_COUNT,
-	CNODE_PROP_LAST
-};
-
 static GObjectClass *parent_class;
 
 static GParamSpec *bn_properties[BLNODE_PROP_LAST];
-static GParamSpec *cn_properties[CNODE_PROP_LAST];
 
 /**************************************************************************/
 /* Buddy list node API                                                    */
@@ -447,216 +422,3 @@ purple_blist_node_get_type(void)
 	return type;
 }
 
-/**************************************************************************/
-/* Counting node API                                                      */
-/**************************************************************************/
-
-int
-purple_counting_node_get_total_size(PurpleCountingNode *counter)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_val_if_fail(priv != NULL, -1);
-
-	return priv->totalsize;
-}
-
-int
-purple_counting_node_get_current_size(PurpleCountingNode *counter)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_val_if_fail(priv != NULL, -1);
-
-	return priv->currentsize;
-}
-
-int
-purple_counting_node_get_online_count(PurpleCountingNode *counter)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_val_if_fail(priv != NULL, -1);
-
-	return priv->onlinecount;
-}
-
-void
-purple_counting_node_change_total_size(PurpleCountingNode *counter, int delta)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_if_fail(priv != NULL);
-
-	purple_counting_node_set_total_size(counter, priv->totalsize + delta);
-}
-
-void
-purple_counting_node_change_current_size(PurpleCountingNode *counter, int delta)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_if_fail(priv != NULL);
-
-	purple_counting_node_set_current_size(counter, priv->currentsize + delta);
-}
-
-void
-purple_counting_node_change_online_count(PurpleCountingNode *counter, int delta)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_if_fail(priv != NULL);
-
-	purple_counting_node_set_online_count(counter, priv->onlinecount + delta);
-}
-
-void
-purple_counting_node_set_total_size(PurpleCountingNode *counter, int totalsize)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_if_fail(priv != NULL);
-
-	priv->totalsize = totalsize;
-
-	g_object_notify_by_pspec(G_OBJECT(counter),
-			cn_properties[CNODE_PROP_TOTAL_SIZE]);
-}
-
-void
-purple_counting_node_set_current_size(PurpleCountingNode *counter, int currentsize)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_if_fail(priv != NULL);
-
-	priv->currentsize = currentsize;
-
-	g_object_notify_by_pspec(G_OBJECT(counter),
-			cn_properties[CNODE_PROP_CURRENT_SIZE]);
-}
-
-void
-purple_counting_node_set_online_count(PurpleCountingNode *counter, int onlinecount)
-{
-	PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
-
-	g_return_if_fail(priv != NULL);
-
-	priv->onlinecount = onlinecount;
-
-	g_object_notify_by_pspec(G_OBJECT(counter),
-			cn_properties[CNODE_PROP_ONLINE_COUNT]);
-}
-
-/**************************************************************************
- * GObject code for PurpleCountingNode
- **************************************************************************/
- 
-/* Set method for GObject properties */
-static void
-purple_counting_node_set_property(GObject *obj, guint param_id, const GValue *value,
-		GParamSpec *pspec)
-{
-	PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
-
-	switch (param_id) {
-		case CNODE_PROP_TOTAL_SIZE:
-			purple_counting_node_set_total_size(node, g_value_get_int(value));
-			break;
-		case CNODE_PROP_CURRENT_SIZE:
-			purple_counting_node_set_current_size(node, g_value_get_int(value));
-			break;
-		case CNODE_PROP_ONLINE_COUNT:
-			purple_counting_node_set_online_count(node, g_value_get_int(value));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-/* Get method for GObject properties */
-static void
-purple_counting_node_get_property(GObject *obj, guint param_id, GValue *value,
-		GParamSpec *pspec)
-{
-	PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
-
-	switch (param_id) {
-		case CNODE_PROP_TOTAL_SIZE:
-			g_value_set_int(value, purple_counting_node_get_total_size(node));
-			break;
-		case CNODE_PROP_CURRENT_SIZE:
-			g_value_set_int(value, purple_counting_node_get_current_size(node));
-			break;
-		case CNODE_PROP_ONLINE_COUNT:
-			g_value_set_int(value, purple_counting_node_get_online_count(node));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-/* Class initializer function */
-static void
-purple_counting_node_class_init(PurpleCountingNodeClass *klass)
-{
-	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
-	/* Setup properties */
-	obj_class->get_property = purple_counting_node_get_property;
-	obj_class->set_property = purple_counting_node_set_property;
-
-	g_type_class_add_private(klass, sizeof(PurpleCountingNodePrivate));
-
-	cn_properties[CNODE_PROP_TOTAL_SIZE] = g_param_spec_int("total-size",
-				"Total size",
-				"The number of children under this node.",
-				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE |
-				G_PARAM_STATIC_STRINGS);
-
-	cn_properties[CNODE_PROP_CURRENT_SIZE] = g_param_spec_int("current-size",
-				"Current size",
-				"The number of children with online accounts.",
-				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE |
-				G_PARAM_STATIC_STRINGS);
-
-	cn_properties[CNODE_PROP_ONLINE_COUNT] = g_param_spec_int("online-count",
-				"Online count",
-				"The number of children that are online.",
-				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE |
-				G_PARAM_STATIC_STRINGS);
-
-	g_object_class_install_properties(obj_class, CNODE_PROP_LAST,
-				cn_properties);
-}
-
-GType
-purple_counting_node_get_type(void)
-{
-	static GType type = 0;
-
-	if(type == 0) {
-		static const GTypeInfo info = {
-			sizeof(PurpleCountingNodeClass),
-			NULL,
-			NULL,
-			(GClassInitFunc)purple_counting_node_class_init,
-			NULL,
-			NULL,
-			sizeof(PurpleCountingNode),
-			0,
-			NULL,
-			NULL,
-		};
-
-		type = g_type_register_static(PURPLE_TYPE_BLIST_NODE,
-				"PurpleCountingNode",
-				&info, G_TYPE_FLAG_ABSTRACT);
-	}
-
-	return type;
-}
diff --git a/libpurple/blistnode.h b/libpurple/blistnode.h
--- a/libpurple/blistnode.h
+++ b/libpurple/blistnode.h
@@ -19,8 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 
-#ifndef _PURPLE_BLIST_NODE_H_
-#define _PURPLE_BLIST_NODE_H_
+#ifndef PURPLE_BLIST_NODE_H
+#define PURPLE_BLIST_NODE_H
 /**
  * SECTION:blistnode
  * @section_id: libpurple-blistnode
@@ -41,20 +41,6 @@
 typedef struct _PurpleBlistNode PurpleBlistNode;
 typedef struct _PurpleBlistNodeClass PurpleBlistNodeClass;
 
-#define PURPLE_TYPE_COUNTING_NODE             (purple_counting_node_get_type())

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits