Mercurial > pidgin.yaz
comparison src/gtkblist.c @ 11742:dfb66f3f9e87
[gaim-migrate @ 14033]
Removes Tools > Plugin Actions and lets plugins add items directly to Tools:wq
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 23 Oct 2005 08:00:29 +0000 |
parents | 7e0ad3b6882a |
children | dd7e9ef6339f |
comparison
equal
deleted
inserted
replaced
11741:8034f752feae | 11742:dfb66f3f9e87 |
---|---|
98 GList *entries; | 98 GList *entries; |
99 } GaimGtkJoinChatData; | 99 } GaimGtkJoinChatData; |
100 | 100 |
101 | 101 |
102 static GtkWidget *protomenu = NULL; | 102 static GtkWidget *protomenu = NULL; |
103 static GtkWidget *pluginmenu = NULL; | |
104 | 103 |
105 GSList *gaim_gtk_blist_sort_methods = NULL; | 104 GSList *gaim_gtk_blist_sort_methods = NULL; |
106 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; | 105 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; |
107 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); | 106 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); |
108 | 107 |
3190 gtk_widget_show(menu); | 3189 gtk_widget_show(menu); |
3191 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); | 3190 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); |
3192 | 3191 |
3193 gtkblist->bpmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounce")); | 3192 gtkblist->bpmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounce")); |
3194 protomenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Account Actions")); | 3193 protomenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Account Actions")); |
3195 pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Plugin Actions")); | |
3196 | 3194 |
3197 /****************************** GtkTreeView **********************************/ | 3195 /****************************** GtkTreeView **********************************/ |
3198 sw = gtk_scrolled_window_new(NULL,NULL); | 3196 sw = gtk_scrolled_window_new(NULL,NULL); |
3199 gtk_widget_show(sw); | 3197 gtk_widget_show(sw); |
3200 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | 3198 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3851 gtkblist->treemodel = NULL; | 3849 gtkblist->treemodel = NULL; |
3852 gtkblist->idle_column = NULL; | 3850 gtkblist->idle_column = NULL; |
3853 gtkblist->buddy_icon_column = NULL; | 3851 gtkblist->buddy_icon_column = NULL; |
3854 g_object_unref(G_OBJECT(gtkblist->ift)); | 3852 g_object_unref(G_OBJECT(gtkblist->ift)); |
3855 protomenu = NULL; | 3853 protomenu = NULL; |
3856 pluginmenu = NULL; | |
3857 gtkblist = NULL; | 3854 gtkblist = NULL; |
3858 | 3855 |
3859 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); | 3856 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); |
3860 } | 3857 } |
3861 | 3858 |
4928 { | 4925 { |
4929 if (pam->callback) | 4926 if (pam->callback) |
4930 pam->callback(pam); | 4927 pam->callback(pam); |
4931 } | 4928 } |
4932 | 4929 |
4930 static GList *plugin_menu_items = NULL; | |
4931 static int plugin_menu_index = 8; | |
4932 | |
4933 static void | 4933 static void |
4934 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin, gpointer context) | 4934 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin, gpointer context) |
4935 { | 4935 { |
4936 GtkWidget *menuitem = NULL; | 4936 GtkWidget *menuitem = NULL; |
4937 GaimPluginAction *action = NULL; | 4937 GaimPluginAction *action = NULL; |
4942 action = (GaimPluginAction *) l->data; | 4942 action = (GaimPluginAction *) l->data; |
4943 action->plugin = plugin; | 4943 action->plugin = plugin; |
4944 action->context = context; | 4944 action->context = context; |
4945 | 4945 |
4946 menuitem = gtk_menu_item_new_with_label(action->label); | 4946 menuitem = gtk_menu_item_new_with_label(action->label); |
4947 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | 4947 plugin_menu_items = g_list_append(plugin_menu_items, menuitem); |
4948 plugin_menu_index++; | |
4949 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, plugin_menu_index); | |
4948 g_signal_connect(G_OBJECT(menuitem), "activate", | 4950 g_signal_connect(G_OBJECT(menuitem), "activate", |
4949 G_CALLBACK(plugin_act), action); | 4951 G_CALLBACK(plugin_act), action); |
4950 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); | 4952 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); |
4951 gtk_widget_show(menuitem); | 4953 gtk_widget_show(menuitem); |
4952 } | 4954 } |
5058 } | 5060 } |
5059 | 5061 |
5060 void | 5062 void |
5061 gaim_gtk_blist_update_plugin_actions(void) | 5063 gaim_gtk_blist_update_plugin_actions(void) |
5062 { | 5064 { |
5063 GtkWidget *menuitem, *submenu; | 5065 GtkWidget *menuitem; |
5064 GaimPlugin *plugin = NULL; | 5066 GaimPlugin *plugin = NULL; |
5065 GList *l; | 5067 GList *l; |
5066 int count = 0; | 5068 int count = 0; |
5067 | 5069 |
5070 GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools")); | |
5071 | |
5068 if (pluginmenu == NULL) | 5072 if (pluginmenu == NULL) |
5069 return; | 5073 return; |
5070 | 5074 |
5071 /* Clear the old Account Actions menu */ | 5075 /* Clear the old Account Actions menu */ |
5072 for (l = gtk_container_get_children(GTK_CONTAINER(pluginmenu)); l; l = l->next) { | 5076 for (l = plugin_menu_items; l; l = l->next) { |
5073 GaimPluginAction *action; | 5077 GaimPluginAction *action; |
5074 | 5078 plugin_menu_index--; |
5075 menuitem = l->data; | 5079 menuitem = l->data; |
5076 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); | 5080 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); |
5077 g_free(action); | 5081 g_free(action); |
5078 | 5082 |
5079 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(menuitem)); | 5083 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(menuitem)); |
5080 } | 5084 } |
5085 g_list_free(plugin_menu_items); | |
5086 plugin_menu_items = NULL; | |
5081 | 5087 |
5082 /* Count the number of plugins with actions */ | 5088 /* Count the number of plugins with actions */ |
5083 for (l = gaim_plugins_get_loaded(); l; l = l->next) { | 5089 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
5084 plugin = (GaimPlugin *) l->data; | 5090 plugin = (GaimPlugin *) l->data; |
5085 | 5091 |
5089 /* no need to count past 2, so don't */ | 5095 /* no need to count past 2, so don't */ |
5090 if (count > 1) | 5096 if (count > 1) |
5091 break; | 5097 break; |
5092 } | 5098 } |
5093 | 5099 |
5094 if (count == 0) { | 5100 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
5095 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | 5101 |
5096 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); | 5102 plugin = (GaimPlugin *) l->data; |
5097 gtk_widget_set_sensitive(menuitem, FALSE); | 5103 |
5098 gtk_widget_show(menuitem); | 5104 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5099 } | 5105 continue; |
5100 | 5106 |
5101 else if (count == 1) { | 5107 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
5102 /* Find the one plugin that has actions */ | 5108 continue; |
5103 for (l = gaim_plugins_get_loaded(); l; l = l->next) { | |
5104 plugin = (GaimPlugin *) l->data; | |
5105 | |
5106 if (!GAIM_IS_PROTOCOL_PLUGIN(plugin) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5107 break; | |
5108 } | |
5109 | 5109 |
5110 build_plugin_actions(pluginmenu, plugin, NULL); | 5110 build_plugin_actions(pluginmenu, plugin, NULL); |
5111 } | 5111 |
5112 | 5112 } |
5113 else { | 5113 } |
5114 for (l = gaim_plugins_get_loaded(); l; l = l->next) { | |
5115 plugin = (GaimPlugin *) l->data; | |
5116 | |
5117 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) | |
5118 continue; | |
5119 | |
5120 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5121 continue; | |
5122 | |
5123 menuitem = gtk_image_menu_item_new_with_label(plugin->info->name); | |
5124 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); | |
5125 gtk_widget_show(menuitem); | |
5126 | |
5127 submenu = gtk_menu_new(); | |
5128 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5129 gtk_widget_show(submenu); | |
5130 | |
5131 build_plugin_actions(submenu, plugin, NULL); | |
5132 } | |
5133 } | |
5134 } |