| 8106 pam->callback(pam); |
8106 pam->callback(pam); |
| 8107 } |
8107 } |
| 8108 |
8108 |
| 8109 static void |
8109 static void |
| 8110 build_plugin_actions(GtkActionGroup *action_group, GString *ui, char *parent, |
8110 build_plugin_actions(GtkActionGroup *action_group, GString *ui, char *parent, |
| 8111 PurplePlugin *plugin, gpointer context) |
8111 PurplePlugin *plugin) |
| 8112 { |
8112 { |
| 8113 GtkAction *menuaction; |
8113 GtkAction *menuaction; |
| |
8114 PurplePluginGetActionsCallback get_actions; |
| 8114 PurplePluginAction *action = NULL; |
8115 PurplePluginAction *action = NULL; |
| 8115 GList *actions, *l; |
8116 GList *actions, *l; |
| 8116 char *name; |
8117 char *name; |
| 8117 int count = 0; |
8118 int count = 0; |
| 8118 |
8119 |
| 8119 actions = PURPLE_PLUGIN_ACTIONS(plugin, context); |
8120 get_actions = |
| |
8121 purple_plugin_info_get_actions_callback(purple_plugin_get_info(plugin)); |
| |
8122 |
| |
8123 actions = get_actions(plugin); |
| 8120 |
8124 |
| 8121 for (l = actions; l != NULL; l = l->next) { |
8125 for (l = actions; l != NULL; l = l->next) { |
| 8122 if (l->data) { |
8126 if (l->data) { |
| 8123 action = (PurplePluginAction *)l->data; |
8127 action = (PurplePluginAction *)l->data; |
| 8124 action->plugin = plugin; |
8128 action->plugin = plugin; |
| 8125 action->context = context; |
|
| 8126 |
8129 |
| 8127 name = g_strdup_printf("%s-action-%d", parent, count++); |
8130 name = g_strdup_printf("%s-action-%d", parent, count++); |
| 8128 menuaction = gtk_action_new(name, action->label, NULL, NULL); |
8131 menuaction = gtk_action_new(name, action->label, NULL, NULL); |
| 8129 gtk_action_group_add_action(action_group, menuaction); |
8132 gtk_action_group_add_action(action_group, menuaction); |
| 8130 g_string_append_printf(ui, "<menuitem action='%s'/>", name); |
8133 g_string_append_printf(ui, "<menuitem action='%s'/>", name); |
| 8166 disable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
8169 disable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
| 8167 { |
8170 { |
| 8168 PurpleAccount *account = data; |
8171 PurpleAccount *account = data; |
| 8169 |
8172 |
| 8170 purple_account_set_enabled(account, PIDGIN_UI, FALSE); |
8173 purple_account_set_enabled(account, PIDGIN_UI, FALSE); |
| |
8174 } |
| |
8175 |
| |
8176 static void |
| |
8177 protocol_act(GtkWidget *obj, PurpleProtocolAction *pam) |
| |
8178 { |
| |
8179 if (pam && pam->callback) |
| |
8180 pam->callback(pam); |
| 8171 } |
8181 } |
| 8172 |
8182 |
| 8173 void |
8183 void |
| 8174 pidgin_blist_update_accounts_menu(void) |
8184 pidgin_blist_update_accounts_menu(void) |
| 8175 { |
8185 { |
| 8249 char *accel_path_buf = NULL; |
8259 char *accel_path_buf = NULL; |
| 8250 GtkWidget *image = NULL; |
8260 GtkWidget *image = NULL; |
| 8251 PurpleConnection *gc = NULL; |
8261 PurpleConnection *gc = NULL; |
| 8252 PurpleAccount *account = NULL; |
8262 PurpleAccount *account = NULL; |
| 8253 GdkPixbuf *pixbuf = NULL; |
8263 GdkPixbuf *pixbuf = NULL; |
| 8254 PurplePlugin *plugin = NULL; |
|
| 8255 PurplePluginProtocolInfo *prpl_info; |
8264 PurplePluginProtocolInfo *prpl_info; |
| 8256 |
8265 |
| 8257 account = accounts->data; |
8266 account = accounts->data; |
| 8258 |
8267 |
| 8259 if (!purple_account_get_enabled(account, PIDGIN_UI)) |
8268 if (!purple_account_get_enabled(account, PIDGIN_UI)) |
| 8290 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
8299 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
| 8291 |
8300 |
| 8292 pidgin_separator(submenu); |
8301 pidgin_separator(submenu); |
| 8293 |
8302 |
| 8294 gc = purple_account_get_connection(account); |
8303 gc = purple_account_get_connection(account); |
| 8295 plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? purple_connection_get_prpl(gc) : NULL; |
8304 prpl_info = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? |
| 8296 prpl_info = plugin ? PURPLE_PLUGIN_PROTOCOL_INFO(plugin) : NULL; |
8305 purple_connection_get_protocol_info(gc) : NULL; |
| 8297 |
8306 |
| 8298 if (prpl_info && |
8307 if (prpl_info && |
| 8299 (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) || |
8308 (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) || |
| 8300 PURPLE_PLUGIN_HAS_ACTIONS(plugin))) { |
8309 PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_actions))) { |
| 8301 if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) && |
8310 if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) && |
| 8302 (purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_SUPPORT_MOODS)) { |
8311 (purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_SUPPORT_MOODS)) { |
| 8303 |
8312 |
| 8304 if (purple_account_get_status(account, "mood")) { |
8313 if (purple_account_get_status(account, "mood")) { |
| 8305 menuitem = gtk_menu_item_new_with_mnemonic(_("Set _Mood...")); |
8314 menuitem = gtk_menu_item_new_with_mnemonic(_("Set _Mood...")); |
| 8307 G_CALLBACK(set_mood_cb), account); |
8316 G_CALLBACK(set_mood_cb), account); |
| 8308 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
8317 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
| 8309 } |
8318 } |
| 8310 } |
8319 } |
| 8311 |
8320 |
| 8312 if (PURPLE_PLUGIN_HAS_ACTIONS(plugin)) { |
8321 if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_actions)) { |
| 8313 GtkWidget *menuitem; |
8322 GtkWidget *menuitem; |
| 8314 PurplePluginAction *action = NULL; |
8323 PurpleProtocolAction *action = NULL; |
| 8315 GList *actions, *l; |
8324 GList *actions, *l; |
| 8316 |
8325 |
| 8317 actions = PURPLE_PLUGIN_ACTIONS(plugin, gc); |
8326 actions = prpl_info->get_actions(gc); |
| 8318 |
8327 |
| 8319 for (l = actions; l != NULL; l = l->next) |
8328 for (l = actions; l != NULL; l = l->next) |
| 8320 { |
8329 { |
| 8321 if (l->data) |
8330 if (l->data) |
| 8322 { |
8331 { |
| 8323 action = (PurplePluginAction *) l->data; |
8332 action = (PurpleProtocolAction *) l->data; |
| 8324 action->plugin = plugin; |
8333 action->connection = gc; |
| 8325 action->context = gc; |
|
| 8326 |
8334 |
| 8327 menuitem = gtk_menu_item_new_with_label(action->label); |
8335 menuitem = gtk_menu_item_new_with_label(action->label); |
| 8328 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
8336 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
| 8329 |
8337 |
| 8330 g_signal_connect(G_OBJECT(menuitem), "activate", |
8338 g_signal_connect(G_OBJECT(menuitem), "activate", |
| 8331 G_CALLBACK(plugin_act), action); |
8339 G_CALLBACK(protocol_act), action); |
| 8332 g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", |
8340 g_object_set_data_full(G_OBJECT(menuitem), "protocol_action", |
| 8333 action, |
8341 action, |
| 8334 (GDestroyNotify)purple_plugin_action_free); |
8342 (GDestroyNotify)purple_protocol_action_free); |
| 8335 gtk_widget_show(menuitem); |
8343 gtk_widget_show(menuitem); |
| 8336 } |
8344 } |
| 8337 else |
8345 else |
| 8338 pidgin_separator(submenu); |
8346 pidgin_separator(submenu); |
| 8339 } |
8347 } |
| 8390 /* Add a submenu for each plugin with custom actions */ |
8399 /* Add a submenu for each plugin with custom actions */ |
| 8391 for (l = purple_plugins_get_loaded(); l; l = l->next) { |
8400 for (l = purple_plugins_get_loaded(); l; l = l->next) { |
| 8392 char *name; |
8401 char *name; |
| 8393 |
8402 |
| 8394 plugin = (PurplePlugin *)l->data; |
8403 plugin = (PurplePlugin *)l->data; |
| 8395 |
8404 info = purple_plugin_get_info(plugin); |
| 8396 if (PURPLE_IS_PROTOCOL_PLUGIN(plugin)) |
8405 |
| |
8406 if (!purple_plugin_info_get_actions_callback(info)) |
| 8397 continue; |
8407 continue; |
| 8398 |
8408 |
| 8399 if (!PURPLE_PLUGIN_HAS_ACTIONS(plugin)) |
|
| 8400 continue; |
|
| 8401 |
|
| 8402 name = g_strdup_printf("plugin%d", count); |
8409 name = g_strdup_printf("plugin%d", count); |
| 8403 action = gtk_action_new(name, plugin->info->name, NULL, NULL); |
8410 action = gtk_action_new(name, purple_plugin_info_get_name(info), NULL, NULL); |
| 8404 gtk_action_group_add_action(plugins_action_group, action); |
8411 gtk_action_group_add_action(plugins_action_group, action); |
| 8405 g_string_append_printf(plugins_ui, "<menu action='%s'>", name); |
8412 g_string_append_printf(plugins_ui, "<menu action='%s'>", name); |
| 8406 |
8413 |
| 8407 build_plugin_actions(plugins_action_group, plugins_ui, name, plugin, NULL); |
8414 build_plugin_actions(plugins_action_group, plugins_ui, name, plugin); |
| 8408 |
8415 |
| 8409 g_string_append(plugins_ui, "</menu>"); |
8416 g_string_append(plugins_ui, "</menu>"); |
| 8410 count++; |
8417 count++; |
| 8411 |
8418 |
| 8412 g_free(name); |
8419 g_free(name); |