Mercurial > pidgin
diff src/gtkutils.c @ 5644:213e999fa5cc
[gaim-migrate @ 6058]
Added a generic function for creating and automatically filling a drop-down
with a list of loaded protocols plugins, and used it in the new account
editor.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Sun, 01 Jun 2003 23:14:31 +0000 |
| parents | 5e9babc828c4 |
| children | 48c63ee49961 |
line wrap: on
line diff
--- a/src/gtkutils.c Sun Jun 01 21:36:40 2003 +0000 +++ b/src/gtkutils.c Sun Jun 01 23:14:31 2003 +0000 @@ -523,3 +523,50 @@ return vbox; } +GtkWidget * +gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, + gpointer user_data) +{ + GaimPluginProtocolInfo *prpl_info; + GaimPlugin *plugin; + GtkWidget *optmenu; + GtkWidget *menu; + GtkWidget *item; + GList *p; + int i; + int selected_index = -1; + + optmenu = gtk_option_menu_new(); + gtk_widget_show(optmenu); + + menu = gtk_menu_new(); + gtk_widget_show(menu); + + for (p = gaim_plugins_get_protocols(), i = 0; + p != NULL; + p = p->next, i++) { + + plugin = (GaimPlugin *)p->data; + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + item = gtk_menu_item_new_with_label(plugin->info->name); + + g_object_set_data(G_OBJECT(item), "user_data", user_data); + + g_signal_connect(G_OBJECT(item), "activate", + cb, GINT_TO_POINTER(prpl_info->protocol)); + + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_widget_show(item); + + if (prpl_info->protocol == protocol) + selected_index = i; + } + + gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); + + if (selected_index != -1) + gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); + + return optmenu; +}
