/soc/2013/ankitkv/gobjectification: 477889a0073c: Refactored gtk...
Ankit Vani
a at nevitus.org
Fri Aug 2 17:29:40 EDT 2013
Changeset: 477889a0073c0ce09d25cc76e25a2313c71307b8
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-03 02:59 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/477889a0073c
Description:
Refactored gtkroomlist, gtkstatusbox, gtkthemes, gtkutils, gtkwebviewtoolbar, smileyparser to use the new API
diffstat:
pidgin/gtkroomlist.c | 4 +-
pidgin/gtkstatusbox.c | 72 +++++++++++++++++++++------------------------
pidgin/gtkthemes.c | 6 +-
pidgin/gtkutils.c | 50 +++++++++++++------------------
pidgin/gtkwebviewtoolbar.c | 6 +-
pidgin/smileyparser.c | 6 +-
6 files changed, 65 insertions(+), 79 deletions(-)
diffs (truncated from 347 to 300 lines):
diff --git a/pidgin/gtkroomlist.c b/pidgin/gtkroomlist.c
--- a/pidgin/gtkroomlist.c
+++ b/pidgin/gtkroomlist.c
@@ -233,7 +233,7 @@ static void do_add_room_cb(GtkWidget *w,
PurplePluginProtocolInfo *prpl_info = NULL;
if(gc != NULL)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+ prpl_info = purple_connection_get_protocol_info(gc);
if(prpl_info != NULL && prpl_info->roomlist_room_serialize)
name = prpl_info->roomlist_room_serialize(info->room);
@@ -540,7 +540,7 @@ static gboolean account_filter_func(Purp
PurplePluginProtocolInfo *prpl_info = NULL;
if (conn && PURPLE_CONNECTION_IS_CONNECTED(conn))
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(conn));
+ prpl_info = purple_connection_get_protocol_info(conn);
return (prpl_info && prpl_info->roomlist_get_list != NULL);
}
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -494,12 +494,10 @@ pidgin_status_box_set_property(GObject *
case PROP_ICON_SEL:
if (g_value_get_boolean(value)) {
if (statusbox->account) {
- PurplePlugin *plug = purple_plugins_find_with_id(purple_account_get_protocol_id(statusbox->account));
- if (plug) {
- PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug);
- if (prplinfo && prplinfo->icon_spec.format != NULL)
- setup_icon_box(statusbox);
- }
+ PurplePluginProtocolInfo *prpl_info =
+ purple_find_protocol_info(purple_account_get_protocol_id(statusbox->account));
+ if (prpl_info && prpl_info->icon_spec.format != NULL)
+ setup_icon_box(statusbox);
} else {
setup_icon_box(statusbox);
}
@@ -1452,44 +1450,40 @@ buddy_icon_set_cb(const char *filename,
PurpleStoredImage *img = NULL;
if (box->account) {
- PurplePlugin *plug = purple_find_protocol_info(purple_account_get_protocol_id(box->account));
- if (plug) {
- PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug);
- if (prplinfo && prplinfo->icon_spec.format) {
- gpointer data = NULL;
- size_t len = 0;
- if (filename)
- data = pidgin_convert_buddy_icon(plug, filename, &len);
- img = purple_buddy_icons_set_account_icon(box->account, data, len);
- if (img)
- /*
- * set_account_icon doesn't give us a reference, but we
- * unref one below (for the other code path)
- */
- purple_imgstore_ref(img);
-
- purple_account_set_buddy_icon_path(box->account, filename);
-
- purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL));
- }
+ PurplePluginProtocolInfo *prpl_info =
+ purple_find_protocol_info(purple_account_get_protocol_id(box->account));
+ if (prpl_info && prpl_info->icon_spec.format) {
+ gpointer data = NULL;
+ size_t len = 0;
+ if (filename)
+ data = pidgin_convert_buddy_icon(prpl_info, filename, &len);
+ img = purple_buddy_icons_set_account_icon(box->account, data, len);
+ if (img)
+ /*
+ * set_account_icon doesn't give us a reference, but we
+ * unref one below (for the other code path)
+ */
+ purple_imgstore_ref(img);
+
+ purple_account_set_buddy_icon_path(box->account, filename);
+
+ purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL));
}
} else {
GList *accounts;
for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) {
PurpleAccount *account = accounts->data;
- PurplePlugin *plug = purple_find_protocol_info(purple_account_get_protocol_id(account));
- if (plug) {
- PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug);
- if (prplinfo != NULL &&
- purple_account_get_bool(account, "use-global-buddyicon", TRUE) &&
- prplinfo->icon_spec.format) {
- gpointer data = NULL;
- size_t len = 0;
- if (filename)
- data = pidgin_convert_buddy_icon(plug, filename, &len);
- purple_buddy_icons_set_account_icon(account, data, len);
- purple_account_set_buddy_icon_path(account, filename);
- }
+ PurplePluginProtocolInfo *prpl_info =
+ purple_find_protocol_info(purple_account_get_protocol_id(account));
+ if (prpl_info != NULL &&
+ purple_account_get_bool(account, "use-global-buddyicon", TRUE) &&
+ prpl_info->icon_spec.format) {
+ gpointer data = NULL;
+ size_t len = 0;
+ if (filename)
+ data = pidgin_convert_buddy_icon(prpl_info, filename, &len);
+ purple_buddy_icons_set_account_icon(account, data, len);
+ purple_account_set_buddy_icon_path(account, filename);
}
}
diff --git a/pidgin/gtkthemes.c b/pidgin/gtkthemes.c
--- a/pidgin/gtkthemes.c
+++ b/pidgin/gtkthemes.c
@@ -396,7 +396,7 @@ void pidgin_themes_smiley_theme_probe()
}
GSList *pidgin_themes_get_proto_smileys(const char *id) {
- PurplePlugin *proto;
+ PurplePluginProtocolInfo *prpl_info;
struct smiley_list *list, *def;
if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL))
@@ -407,12 +407,12 @@ GSList *pidgin_themes_get_proto_smileys(
if (id == NULL)
return def->smileys;
- proto = purple_find_protocol_info(id);
+ prpl_info = purple_find_protocol_info(id);
while (list) {
if (!strcmp(list->sml, "default"))
def = list;
- else if (proto && !strcmp(proto->info->name, list->sml))
+ else if (prpl_info && !strcmp(prpl_info->name, list->sml))
break;
list = list->next;
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -552,15 +552,13 @@ aop_option_menu_replace_menu(GtkWidget *
}
static GdkPixbuf *
-pidgin_create_prpl_icon_from_prpl(PurplePlugin *prpl, PidginPrplIconSize size, PurpleAccount *account)
+pidgin_create_prpl_icon_from_protocol(PurplePluginProtocolInfo *prpl_info, PidginPrplIconSize size, PurpleAccount *account)
{
- PurplePluginProtocolInfo *prpl_info;
const char *protoname = NULL;
char *tmp;
char *filename = NULL;
GdkPixbuf *pixbuf;
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
if (prpl_info->list_icon == NULL)
return NULL;
@@ -629,7 +627,7 @@ static AopMenu *
create_protocols_menu(const char *default_proto_id)
{
AopMenu *aop_menu = NULL;
- PurplePlugin *plugin;
+ PurplePluginProtocolInfo *prpl_info;
GdkPixbuf *pixbuf = NULL;
GtkTreeIter iter;
GtkListStore *ls;
@@ -642,25 +640,25 @@ create_protocols_menu(const char *defaul
aop_menu->default_item = 0;
aop_menu->model = GTK_TREE_MODEL(ls);
- for (p = purple_plugins_get_protocols(), i = 0;
+ for (p = purple_protocols_get_all(), i = 0;
p != NULL;
p = p->next, i++) {
- plugin = (PurplePlugin *)p->data;
-
- pixbuf = pidgin_create_prpl_icon_from_prpl(plugin, PIDGIN_PRPL_ICON_SMALL, NULL);
+ prpl_info = (PurplePluginProtocolInfo *)p->data;
+
+ pixbuf = pidgin_create_prpl_icon_from_protocol(prpl_info, PIDGIN_PRPL_ICON_SMALL, NULL);
gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter,
AOP_ICON_COLUMN, pixbuf,
- AOP_NAME_COLUMN, plugin->info->name,
- AOP_DATA_COLUMN, plugin->info->id,
+ AOP_NAME_COLUMN, prpl_info->name,
+ AOP_DATA_COLUMN, prpl_info->id,
-1);
if (pixbuf)
g_object_unref(pixbuf);
- if (default_proto_id != NULL && !strcmp(plugin->info->id, default_proto_id))
+ if (default_proto_id != NULL && !strcmp(prpl_info->id, default_proto_id))
aop_menu->default_item = i;
}
@@ -921,7 +919,7 @@ void pidgin_retrieve_user_info_in_chat(P
return;
}
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(conn));
+ prpl_info = purple_connection_get_protocol_info(conn);
if (prpl_info != NULL && prpl_info->get_cb_real_name)
who = prpl_info->get_cb_real_name(conn, chat, name);
if (prpl_info == NULL || prpl_info->get_cb_info == NULL) {
@@ -1024,30 +1022,27 @@ pidgin_parse_x_im_contact(const char *ms
{
PurpleConnection *gc;
PurplePluginProtocolInfo *prpl_info = NULL;
- PurplePlugin *plugin;
if (all_accounts)
{
account = (PurpleAccount *)l->data;
- plugin = purple_plugins_find_with_id(
+ prpl_info = purple_find_protocol_info(
purple_account_get_protocol_id(account));
- if (plugin == NULL)
+ if (prpl_info == NULL)
{
account = NULL;
continue;
}
-
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
}
else
{
gc = (PurpleConnection *)l->data;
account = purple_connection_get_account(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+ prpl_info = purple_connection_get_protocol_info(gc);
}
protoname = prpl_info->list_icon(account, NULL);
@@ -1066,30 +1061,27 @@ pidgin_parse_x_im_contact(const char *ms
{
PurpleConnection *gc;
PurplePluginProtocolInfo *prpl_info = NULL;
- PurplePlugin *plugin;
if (all_accounts)
{
account = (PurpleAccount *)l->data;
- plugin = purple_plugins_find_with_id(
+ prpl_info = purple_find_protocol_info(
purple_account_get_protocol_id(account));
- if (plugin == NULL)
+ if (prpl_info == NULL)
{
account = NULL;
continue;
}
-
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
}
else
{
gc = (PurpleConnection *)l->data;
account = purple_connection_get_account(gc);
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+ prpl_info = purple_connection_get_protocol_info(gc);
}
protoname = prpl_info->list_icon(account, NULL);
@@ -1498,7 +1490,7 @@ pidgin_dnd_file_manage(GtkSelectionData
data->account = account;
if (gc)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc));
+ prpl_info = purple_connection_get_protocol_info(gc);
if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE)
im = TRUE;
@@ -1699,14 +1691,14 @@ pidgin_stock_id_from_presence(PurplePres
GdkPixbuf *
pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size)
{
- PurplePlugin *prpl;
+ PurplePluginProtocolInfo *prpl_info;
g_return_val_if_fail(account != NULL, NULL);
- prpl = purple_find_protocol_info(purple_account_get_protocol_id(account));
More information about the Commits
mailing list