gobjectification: 2c344c08: Group add_child

aluink at soc.pidgin.im aluink at soc.pidgin.im
Wed Jul 22 22:20:52 EDT 2009


-----------------------------------------------------------------
Revision: 2c344c08bc11bd04bd881613645fa3d207906769
Ancestor: f7ccc6e1f10fc4b2d1beef2fb06c6ff002b2a2c4
Author: aluink at soc.pidgin.im
Date: 2009-07-23T01:56:30
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/2c344c08bc11bd04bd881613645fa3d207906769

Modified files:
        libpurple/group.c

ChangeLog: 

Group add_child

-------------- next part --------------
============================================================
--- libpurple/group.c	eec07841c4f6965cde85db0f1b4edeca99cbc818
+++ libpurple/group.c	eeab1c08a44cc7f9102a45efd7581518bce7b992
@@ -93,6 +93,42 @@ static void
 }
 
 static void
+purple_group_add_child(PurpleBlistNode *parent, PurpleBlistNode *child)
+{
+	PurpleGroup *group;
+	PurpleChat *chat;
+	PurpleContact *contact;
+
+	g_return_if_fail(parent);
+	g_return_if_fail(child);
+	group = PURPLE_GROUP(parent);
+
+	parent_class->add_child(parent, child);
+
+	if(PURPLE_IS_CHAT(child)){
+		chat = PURPLE_CHAT(child);
+		if (purple_account_is_connected(chat->account)) {
+			group->online++;
+			group->currentsize++;
+		}
+	} else if(PURPLE_IS_CONTACT(child)){
+		contact = PURPLE_CONTACT(child);
+		if(purple_contact_get_online(contact) > 0)
+			group->online++;
+		if(purple_contact_get_currentsize(contact) > 0)
+			group->currentsize++;
+	} else {
+		#warning: is this an ok case?
+		g_warn_if_reached();
+	}
+	group->totalsize++;
+
+	purple_blist_schedule_save();
+	purple_signal_emit(purple_blist_node_get_handle(), "node-added", child);
+
+}
+
+static void
 purple_group_remove_node(PurpleBlistNode *child)
 {
 	PurpleGroup *group;
@@ -116,6 +152,7 @@ purple_group_remove_node(PurpleBlistNode
 		if(purple_contact_get_currentsize(contact) > 0)
 			group->currentsize--;
 	} else {
+		#warning: Is this an ok case?
 		g_warn_if_reached();
 	}
 	group->totalsize--;
@@ -125,7 +162,6 @@ purple_group_remove_node(PurpleBlistNode
 	purple_blist_schedule_save();
 
 	purple_signal_emit(purple_blist_node_get_handle(), "node-removed", child);
-	g_object_unref(G_OBJECT(child));
 }
 
 void
@@ -287,11 +323,13 @@ purple_group_class_init(PurpleGroupClass
 purple_group_class_init(PurpleGroupClass *klass)
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-	PurpleBlistNodeClass *bklass = PURPLE_BLIST_NODE_CLASS(klass);
 
+	parent_class = PURPLE_BLIST_NODE_CLASS(klass);	
+	/* parent_class->add_sibling = purple_group_add_sibling; */
+	parent_class->add_child = purple_group_add_child;
+	parent_class->remove = purple_group_remove_node;
+
 	parent_class = g_type_class_peek_parent(klass);
-	
-	bklass->remove = purple_group_remove_node;
 
 	obj_class->finalize = purple_group_finalize;
 	obj_class->set_property = purple_group_set_property;


More information about the Commits mailing list