/soc/2013/ankitkv/gobjectification: 7f2c0d1ca2d4: Refactored gtk...

Ankit Vani a at nevitus.org
Thu Aug 1 14:08:27 EDT 2013


Changeset: 7f2c0d1ca2d4e0400e31d068f3bb859d7d0d54a0
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-01 23:38 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7f2c0d1ca2d4

Description:

Refactored gtkblist to use the new API

diffstat:

 pidgin/gtkblist.c |  142 ++++++++++++++++++++++-------------------------------
 1 files changed, 59 insertions(+), 83 deletions(-)

diffs (truncated from 452 to 300 lines):

diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -390,7 +390,7 @@ static void gtk_blist_join_chat(PurpleCh
 	char *chat_name;
 
 	account = purple_chat_get_account(chat);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_protocol_info(purple_account_get_protocol_id(account)));
+	prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account));
 
 	components = purple_chat_get_components(chat);
 
@@ -671,7 +671,7 @@ static void chat_components_edit(GtkWidg
 	purple_request_fields_add_group(fields, group);
 
 	gc = purple_account_get_connection(purple_chat_get_account(chat));
-	parts = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc))->chat_info(gc);
+	parts = purple_connection_get_protocol_info(gc)->chat_info(gc);
 
 	for (iter = parts; iter; iter = iter->next) {
 		pce = iter->data;
@@ -751,7 +751,7 @@ static void gtk_blist_menu_showlog_cb(Gt
 		PurplePluginProtocolInfo *prpl_info = NULL;
 		type = PURPLE_LOG_CHAT;
 		account = purple_chat_get_account(c);
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_protocol_info(purple_account_get_protocol_id(account)));
+		prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account));
 		if (prpl_info && prpl_info->get_chat_name) {
 			name = prpl_info->get_chat_name(purple_chat_get_components(c));
 		}
@@ -912,7 +912,7 @@ set_sensitive_if_input_chat_cb(GtkWidget
 	gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), GTK_RESPONSE_OK, sensitive);
 
 	gc = purple_account_get_connection(data->rq_data.account);
-	prpl_info = (gc != NULL) ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc)) : NULL;
+	prpl_info = (gc != NULL) ? purple_connection_get_protocol_info(gc) : NULL;
 	sensitive = (prpl_info != NULL && prpl_info->roomlist_get_list != NULL);
 
 	gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window), 1, sensitive);
@@ -921,16 +921,16 @@ set_sensitive_if_input_chat_cb(GtkWidget
 static void
 set_sensitive_if_input_buddy_cb(GtkWidget *entry, gpointer user_data)
 {
-	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
 	PidginAddBuddyData *data = user_data;
 	const char *text;
 
-	prpl = purple_find_protocol_info(purple_account_get_protocol_id(
+	prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(
 		data->rq_data.account));
 	text = gtk_entry_get_text(GTK_ENTRY(entry));
 
 	gtk_dialog_set_response_sensitive(GTK_DIALOG(data->rq_data.window),
-		GTK_RESPONSE_OK, purple_validate(prpl, text));
+		GTK_RESPONSE_OK, purple_validate(prpl_info, text));
 }
 
 static void
@@ -951,7 +951,7 @@ chat_account_filter_func(PurpleAccount *
 	if (gc == NULL)
 		return FALSE;
 
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+	prpl_info = purple_connection_get_protocol_info(gc);
 
 	return (prpl_info->chat_info != NULL);
 }
@@ -1051,7 +1051,7 @@ rebuild_chat_entries(PidginChatData *dat
 	g_return_if_fail(data->rq_data.account != NULL);
 
 	gc = purple_account_get_connection(data->rq_data.account);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+	prpl_info = purple_connection_get_protocol_info(gc);
 
 	gtk_container_foreach(GTK_CONTAINER(data->rq_data.vbox), (GtkCallback)gtk_widget_destroy, NULL);
 
@@ -1426,7 +1426,7 @@ pidgin_append_blist_node_proto_menu(GtkW
                                       PurpleBlistNode *node)
 {
 	GList *l, *ll;
-	PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+	PurplePluginProtocolInfo *prpl_info = purple_connection_get_protocol_info(gc);
 
 	if(!prpl_info || !prpl_info->blist_node_menu)
 		return;
@@ -1492,7 +1492,7 @@ pidgin_blist_make_buddy_menu(GtkWidget *
 
 	account = purple_buddy_get_account(buddy);
 	pc = purple_account_get_connection(account);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(pc));
+	prpl_info = purple_connection_get_protocol_info(pc);
 
 	node = PURPLE_BLIST_NODE(buddy);
 
@@ -1941,7 +1941,6 @@ gtk_blist_button_press_cb(GtkWidget *tv,
 	PurpleBlistNode *node;
 	GtkTreeIter iter;
 	GtkTreeSelection *sel;
-	PurplePlugin *prpl = NULL;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	struct _pidgin_blist_node *gtknode;
 	gboolean handled = FALSE;
@@ -1975,11 +1974,9 @@ gtk_blist_button_press_cb(GtkWidget *tv,
 		else
 			b = (PurpleBuddy *)node;
 
-		prpl = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(b)));
-		if (prpl != NULL)
-			prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
-		if (prpl && prpl_info->get_info)
+		prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(b)));
+
+		if (prpl_info && prpl_info->get_info)
 			pidgin_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(b)), purple_buddy_get_name(b));
 		handled = TRUE;
 	}
@@ -2318,7 +2315,7 @@ static void pidgin_blist_drag_data_get_c
 		}
 
 		protocol =
-			PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc))->list_icon(purple_buddy_get_account(buddy),
+			purple_connection_get_protocol_info(gc)->list_icon(purple_buddy_get_account(buddy),
 														   buddy);
 
 		str = g_string_new(NULL);
@@ -2695,7 +2692,7 @@ static GdkPixbuf *pidgin_blist_get_buddy
 	}
 
 	if(account && purple_account_get_connection(account)) {
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(purple_account_get_connection(account)));
+		prpl_info = purple_connection_get_protocol_info(purple_account_get_connection(account));
 	}
 
 #if 0
@@ -3521,8 +3518,7 @@ get_global_moods(void)
 			PurpleConnection *gc = purple_account_get_connection(account);
 
 			if (purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_SUPPORT_MOODS) {
-				PurplePluginProtocolInfo *prpl_info =
-					PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+				PurplePluginProtocolInfo *prpl_info = purple_connection_get_protocol_info(gc);
 				PurpleMood *mood = NULL;
 
 				/* PURPLE_CONNECTION_FLAG_SUPPORT_MOODS would not be set if the prpl doesn't
@@ -3616,7 +3612,7 @@ set_mood_cb(GtkWidget *widget, PurpleAcc
 		PurpleStatus *status = purple_presence_get_status(presence, "mood");
 		gc = purple_account_get_connection(account);
 		g_return_if_fail(purple_connection_get_protocol_info(gc) != NULL);
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+		prpl_info = purple_connection_get_protocol_info(gc);
 		current_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
 	} else {
 		current_mood = get_global_mood_status();
@@ -3804,7 +3800,6 @@ static const char *blist_menu =
 static char *pidgin_get_tooltip_text(PurpleBlistNode *node, gboolean full)
 {
 	GString *str = g_string_new("");
-	PurplePlugin *prpl;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	char *tmp;
 
@@ -3819,8 +3814,7 @@ static char *pidgin_get_tooltip_text(Pur
 		PidginBlistNode *bnode = purple_blist_node_get_ui_data(node);
 
 		chat = (PurpleChat *)node;
-		prpl = purple_find_protocol_info(purple_account_get_protocol_id(purple_chat_get_account(chat)));
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+		prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_chat_get_account(chat)));
 
 		connections = purple_connections_get_all();
 		if (connections && connections->next)
@@ -3908,8 +3902,7 @@ static char *pidgin_get_tooltip_text(Pur
 			c = purple_buddy_get_contact(b);
 		}
 
-		prpl = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(b)));
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+		prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(b)));
 
 		presence = purple_buddy_get_presence(b);
 		user_info = purple_notify_user_info_new();
@@ -4108,7 +4101,6 @@ pidgin_blist_get_emblem(PurpleBlistNode 
 {
 	PurpleBuddy *buddy = NULL;
 	struct _pidgin_blist_node *gtknode = purple_blist_node_get_ui_data(node);
-	PurplePlugin *prpl;
 	PurplePluginProtocolInfo *prpl_info;
 	const char *name = NULL;
 	char *filename, *path;
@@ -4177,12 +4169,11 @@ pidgin_blist_get_emblem(PurpleBlistNode 
 		return _pidgin_blist_get_cached_emblem(path);
 	}
 
-	prpl = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(buddy)));
-	if (!prpl)
+	prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(buddy)));
+	if (!prpl_info)
 		return NULL;
 
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	if (prpl_info && prpl_info->list_emblem)
+	if (prpl_info->list_emblem)
 		name = prpl_info->list_emblem(buddy);
 
 	if (name == NULL) {
@@ -4238,15 +4229,15 @@ pidgin_blist_get_status_icon(PurpleBlist
 
 	if(buddy || chat) {
 		PurpleAccount *account;
-		PurplePlugin *prpl;
+		PurplePluginProtocolInfo *prpl_info;
 
 		if(buddy)
 			account = purple_buddy_get_account(buddy);
 		else
 			account = purple_chat_get_account(chat);
 
-		prpl = purple_find_protocol_info(purple_account_get_protocol_id(account));
-		if(!prpl)
+		prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account));
+		if(!prpl_info)
 			return NULL;
 	}
 
@@ -4329,7 +4320,6 @@ pidgin_blist_get_name_markup(PurpleBuddy
 {
 	const char *name, *name_color, *name_font, *status_color, *status_font;
 	char *text = NULL;
-	PurplePlugin *prpl;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	PurpleContact *contact;
 	PurplePresence *presence;
@@ -4379,10 +4369,7 @@ pidgin_blist_get_name_markup(PurpleBuddy
 	if (!aliased || biglist) {
 
 		/* Status Info */
-		prpl = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(b)));
-
-		if (prpl != NULL)
-			prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+		prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_buddy_get_account(b)));
 
 		if (prpl_info && prpl_info->status_text && purple_account_get_connection(purple_buddy_get_account(b))) {
 			char *tmp = prpl_info->status_text(b);
@@ -4666,7 +4653,7 @@ sign_on_off_cb(PurpleConnection *gc, Pur
 }
 
 static void
-plugin_changed_cb(PurplePlugin *p, gpointer data)
+plugin_changed_cb(GPluginPlugin *p, gpointer data)
 {
 	pidgin_blist_update_plugin_actions();
 }
@@ -7167,7 +7154,6 @@ add_buddy_select_account_cb(GObject *w, 
 							PidginAddBuddyData *data)
 {
 	PurpleConnection *pc = NULL;
-	PurplePlugin *prpl = NULL;
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	gboolean invite_enabled = TRUE;
 
@@ -7177,9 +7163,7 @@ add_buddy_select_account_cb(GObject *w, 
 	if (account)
 		pc = purple_account_get_connection(account);
 	if (pc)
-		prpl = purple_connection_get_protocol_info(pc);
-	if (prpl)
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+		prpl_info = purple_connection_get_protocol_info(pc);
 	if (prpl_info && !(prpl_info->options & OPT_PROTO_INVITE_MESSAGE))
 		invite_enabled = FALSE;
 
@@ -7434,7 +7418,7 @@ pidgin_blist_request_add_chat(PurpleAcco
 
 	if (account != NULL) {
 		gc = purple_account_get_connection(account);
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+		prpl_info = purple_connection_get_protocol_info(gc);
 
 		if (prpl_info->join_chat == NULL) {
 			purple_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL);
@@ -7444,7 +7428,7 @@ pidgin_blist_request_add_chat(PurpleAcco
 		/* Find an account with chat capabilities */
 		for (l = purple_connections_get_all(); l != NULL; l = l->next) {
 			gc = (PurpleConnection *)l->data;
-			prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+			prpl_info = purple_connection_get_protocol_info(gc);
 
 			if (prpl_info->join_chat != NULL) {
 				account = purple_connection_get_account(gc);
@@ -8125,7 +8109,7 @@ plugin_act(GtkWidget *obj, PurplePluginA
 
 static void
 build_plugin_actions(GtkActionGroup *action_group, GString *ui, char *parent,
-		PurplePlugin *plugin, gpointer context)
+		PurplePluginInfo *plugin_info)
 {
 	GtkAction *menuaction;



More information about the Commits mailing list