/soc/2013/ankitkv/gobjectification: 7d507b8b9f92: Refactored pid...

Ankit Vani a at nevitus.org
Tue Jul 9 16:12:38 EDT 2013


Changeset: 7d507b8b9f9230cda842261f21a894caeccca1ec
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-10 01:42 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7d507b8b9f92

Description:

Refactored pidgin to use the GObject BList API

diffstat:

 pidgin/gtkconv.c    |   8 +++-----
 pidgin/gtkdialogs.c |  11 ++++++++---
 pidgin/gtklog.c     |  11 +++++------
 pidgin/gtkutils.c   |   4 +++-
 4 files changed, 19 insertions(+), 15 deletions(-)

diffs (113 lines):

diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -3285,8 +3285,7 @@ populate_menu_with_options(GtkWidget *me
 						g_strdup(purple_conversation_get_name(conv)));
 			}
 			chat = purple_chat_new(account, NULL, components);
-			purple_blist_node_set_flags((PurpleBListNode *)chat,
-					PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+			purple_blist_node_set_dont_save((PurpleBListNode *)chat, TRUE);
 			g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_chat",
 					chat, (GDestroyNotify)purple_blist_remove_chat);
 		}
@@ -3300,10 +3299,9 @@ populate_menu_with_options(GtkWidget *me
 
 			if (!buddy) {
 				buddy = purple_buddy_new(account, purple_conversation_get_name(conv), NULL);
-				purple_blist_node_set_flags((PurpleBListNode *)buddy,
-						PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+				purple_blist_node_set_dont_save((PurpleBListNode *)buddy, TRUE);
 				g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_buddy",
-						buddy, (GDestroyNotify)purple_buddy_destroy);
+						buddy, (GDestroyNotify)g_object_unref);
 			}
 		}
 	}
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -1216,11 +1216,15 @@ pidgin_dialogs_alias_chat_cb(PurpleChat 
 void
 pidgin_dialogs_alias_chat(PurpleChat *chat)
 {
+	gchar *alias;
+
 	g_return_if_fail(chat != NULL);
 
+	g_object_get(chat, "alias", &alias, NULL);
+
 	purple_request_input(NULL, _("Alias Chat"), NULL,
 					   _("Enter an alias for this chat."),
-					   chat->alias, FALSE, FALSE, NULL,
+					   alias, FALSE, FALSE, NULL,
 					   _("Alias"), G_CALLBACK(pidgin_dialogs_alias_chat_cb),
 					   _("Cancel"), NULL,
 					   purple_chat_get_account(chat), NULL, NULL,
@@ -1256,6 +1260,7 @@ pidgin_dialogs_remove_contact(PurpleCont
 		pidgin_dialogs_remove_buddy(buddy);
 	} else {
 		gchar *text;
+		int contact_size = purple_counting_node_get_total_size(PURPLE_COUNTING_NODE(contact));
 		text = g_strdup_printf(
 					ngettext(
 						"You are about to remove the contact containing %s "
@@ -1263,8 +1268,8 @@ pidgin_dialogs_remove_contact(PurpleCont
 						"want to continue?",
 						"You are about to remove the contact containing %s "
 						"and %d other buddies from your buddy list.  Do you "
-						"want to continue?", purple_contact_get_contact_size(contact, TRUE) - 1),
-					purple_buddy_get_name(buddy), purple_contact_get_contact_size(contact, TRUE) - 1);
+						"want to continue?", contact_size - 1),
+					purple_buddy_get_name(buddy), contact_size - 1);
 
 		purple_request_action(contact, NULL, _("Remove Contact"), text, 0,
 				NULL, purple_contact_get_alias(contact), NULL,
diff --git a/pidgin/gtklog.c b/pidgin/gtklog.c
--- a/pidgin/gtklog.c
+++ b/pidgin/gtklog.c
@@ -790,17 +790,16 @@ void pidgin_log_show_contact(PurpleConta
 		image = NULL;
 	}
 
-	if (contact->alias != NULL)
-		name = contact->alias;
-	else if (contact->priority != NULL)
-		name = purple_buddy_get_contact_alias(contact->priority);
+	name = purple_contact_get_alias(contact);
 
 	/* This will happen if the contact doesn't have an alias,
 	 * and none of the contact's buddies are online.
 	 * There is probably a better way to deal with this. */
 	if (name == NULL) {
-		if (contact->node.child != NULL && PURPLE_IS_BUDDY(contact->node.child))
-			name = purple_buddy_get_contact_alias((PurpleBuddy *) contact->node.child);
+		if (PURPLE_BLIST_NODE(contact)->child != NULL &&
+				PURPLE_IS_BUDDY(PURPLE_BLIST_NODE(contact)->child))
+			name = purple_buddy_get_contact_alias(PURPLE_BUDDY(
+					PURPLE_BLIST_NODE(contact)->child));
 		if (name == NULL)
 			name = "";
 	}
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -1968,6 +1968,7 @@ add_completion_list(PidginCompletionData
 	PidginFilterBuddyCompletionEntryFunc filter_func = data->filter_func;
 	gpointer user_data = data->filter_func_user_data;
 	GHashTable *sets;
+	gchar *alias;
 
 	gtk_list_store_clear(data->store);
 
@@ -1988,8 +1989,9 @@ add_completion_list(PidginCompletionData
 				entry.entry.buddy = (PurpleBuddy *) bnode;
 
 				if (filter_func(&entry, user_data)) {
+					g_object_get(cnode, "alias", &alias, NULL);
 					add_buddyname_autocomplete_entry(data->store,
-														((PurpleContact *)cnode)->alias,
+														alias,
 														purple_buddy_get_contact_alias(entry.entry.buddy),
 														purple_buddy_get_account(entry.entry.buddy),
 														purple_buddy_get_name(entry.entry.buddy)



More information about the Commits mailing list