/soc/2013/ankitkv/gobjectification: 1c0b40253875: Refactored gtk...
Ankit Vani
a at nevitus.org
Thu Aug 1 18:12:04 EDT 2013
Changeset: 1c0b4025387563150337e42fb940c65a3df3a51c
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-02 03:41 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/1c0b40253875
Description:
Refactored gtkdocklet, gtkimhtmltoolbar, gtkmain to use the new API
diffstat:
pidgin/gtkdocklet.c | 41 +++++++++++++++++++----------------------
pidgin/gtkimhtmltoolbar.c | 6 +++---
pidgin/gtkmain.c | 18 +++++++-----------
3 files changed, 29 insertions(+), 36 deletions(-)
diffs (181 lines):
diff --git a/pidgin/gtkdocklet.c b/pidgin/gtkdocklet.c
--- a/pidgin/gtkdocklet.c
+++ b/pidgin/gtkdocklet.c
@@ -260,7 +260,7 @@ online_account_supports_chat(void)
while(c != NULL) {
PurpleConnection *gc = c->data;
- 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 != NULL && prpl_info->chat_info != NULL)
return TRUE;
c = c->next;
@@ -297,7 +297,7 @@ static void
docklet_signed_on_cb(PurpleConnection *gc)
{
if (!enable_join_chat) {
- if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc))->chat_info != NULL)
+ if (purple_connection_get_protocol_info(gc)->chat_info != NULL)
enable_join_chat = TRUE;
}
docklet_update_status();
@@ -307,7 +307,7 @@ static void
docklet_signed_off_cb(PurpleConnection *gc)
{
if (enable_join_chat) {
- if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_protocol_info(gc))->chat_info != NULL)
+ if (purple_connection_get_protocol_info(gc)->chat_info != NULL)
enable_join_chat = online_account_supports_chat();
}
docklet_update_status();
@@ -623,7 +623,6 @@ docklet_status_submenu(void)
}
-
static void
plugin_act(GtkWidget *widget, PurplePluginAction *pam)
{
@@ -632,38 +631,34 @@ plugin_act(GtkWidget *widget, PurplePlug
}
static void
-build_plugin_actions(GtkWidget *menu, PurplePlugin *plugin,
- gpointer context)
+build_plugin_actions(GtkWidget *menu, GPluginPlugin *plugin)
{
+ PurplePluginInfo *info = PURPLE_PLUGIN_INFO(gplugin_plugin_get_info(plugin));
GtkWidget *menuitem;
PurplePluginAction *action = NULL;
GList *actions, *l;
- actions = PURPLE_PLUGIN_ACTIONS(plugin, context);
+ actions = purple_plugin_info_get_actions(info);
for (l = actions; l != NULL; l = l->next)
{
if (l->data)
{
action = (PurplePluginAction *) l->data;
- action->plugin = plugin;
- action->context = context;
menuitem = gtk_menu_item_new_with_label(action->label);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(plugin_act), action);
- g_object_set_data_full(G_OBJECT(menuitem), "plugin_action",
- action,
- (GDestroyNotify)purple_plugin_action_free);
+ g_object_set_data(G_OBJECT(menuitem), "plugin_action", action);
gtk_widget_show(menuitem);
}
else
pidgin_separator(menu);
}
- g_list_free(actions);
+ g_object_unref(info);
}
@@ -671,7 +666,8 @@ static void
docklet_plugin_actions(GtkWidget *menu)
{
GtkWidget *menuitem, *submenu;
- PurplePlugin *plugin = NULL;
+ GPluginPlugin *plugin = NULL;
+ GPluginPluginInfo *info;
GList *l;
int c = 0;
@@ -679,23 +675,24 @@ docklet_plugin_actions(GtkWidget *menu)
/* Add a submenu for each plugin with custom actions */
for (l = purple_plugins_get_loaded(); l; l = l->next) {
- plugin = (PurplePlugin *) l->data;
+ plugin = GPLUGIN_PLUGIN(l->data);
+ info = gplugin_plugin_get_info(plugin);
- if (PURPLE_IS_PROTOCOL_PLUGIN(plugin))
+ if (!purple_plugin_info_get_actions(PURPLE_PLUGIN_INFO(info))) {
+ g_object_unref(info);
continue;
+ }
- if (!PURPLE_PLUGIN_HAS_ACTIONS(plugin))
- continue;
-
- menuitem = gtk_image_menu_item_new_with_label(_(plugin->info->name));
+ menuitem = gtk_image_menu_item_new_with_label(_(gplugin_plugin_info_get_name(info)));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
submenu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
- build_plugin_actions(submenu, plugin, NULL);
+ build_plugin_actions(submenu, plugin);
+ c++;
- c++;
+ g_object_unref(info);
}
if(c>0)
pidgin_separator(menu);
diff --git a/pidgin/gtkimhtmltoolbar.c b/pidgin/gtkimhtmltoolbar.c
--- a/pidgin/gtkimhtmltoolbar.c
+++ b/pidgin/gtkimhtmltoolbar.c
@@ -1593,14 +1593,14 @@ void gtk_imhtmltoolbar_switch_active_con
PurpleConversation *conv)
{
PurpleConnection *gc = purple_conversation_get_connection(conv);
- PurplePlugin *prpl = purple_connection_get_protocol_info(gc);
+ PurplePluginProtocolInfo *prpl_info = purple_connection_get_protocol_info(gc);
g_object_set_data(G_OBJECT(toolbar), "active_conv", conv);
/* gray out attention button on protocols that don't support it
for the time being it is always disabled for chats */
gtk_widget_set_sensitive(toolbar->attention,
- conv && prpl && PURPLE_IS_IM_CONVERSATION(conv) &&
- PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention != NULL);
+ conv && prpl_info && PURPLE_IS_IM_CONVERSATION(conv) &&
+ prpl_info->send_attention != NULL);
}
diff --git a/pidgin/gtkmain.c b/pidgin/gtkmain.c
--- a/pidgin/gtkmain.c
+++ b/pidgin/gtkmain.c
@@ -745,17 +745,6 @@ int main(int argc, char *argv[])
purple_core_set_ui_ops(pidgin_core_get_ui_ops());
purple_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops());
- /*
- * Set plugin search directories. Give priority to the plugins
- * in user's home directory.
- */
- search_path = g_build_filename(purple_user_dir(), "plugins", NULL);
- if (!g_stat(search_path, &st))
- g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR);
- purple_plugins_add_search_path(search_path);
- g_free(search_path);
- purple_plugins_add_search_path(LIBDIR);
-
if (!purple_core_init(PIDGIN_UI)) {
fprintf(stderr,
"Initialization of the libpurple core failed. Dumping core.\n"
@@ -766,6 +755,13 @@ int main(int argc, char *argv[])
abort();
}
+ search_path = g_build_filename(purple_user_dir(), "plugins", NULL);
+ if (!g_stat(search_path, &st))
+ g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR);
+ gplugin_plugin_manager_append_path(search_path);
+ gplugin_plugin_manager_refresh();
+ g_free(search_path);
+
if (opt_si && !purple_core_ensure_single_instance()) {
#ifdef HAVE_DBUS
DBusConnection *conn = purple_dbus_get_connection();
More information about the Commits
mailing list