Mercurial > pidgin.yaz
changeset 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 | eb685809108b |
children | a9cd11fd0d6f |
files | src/gtkaccount.c src/gtkutils.c src/gtkutils.h |
diffstat | 3 files changed, 69 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkaccount.c Sun Jun 01 21:36:40 2003 +0000 +++ b/src/gtkaccount.c Sun Jun 01 23:14:31 2003 +0000 @@ -97,10 +97,12 @@ /************************************************************************** * Add/Modify Account dialog **************************************************************************/ -static GtkWidget * -__make_protocol_menu(AccountPrefsDialog *dialog) +static void +__set_account_protocol(GtkWidget *item, GaimProtocol protocol) { - return gtk_button_new(); + AccountPrefsDialog *dialog; + + dialog = g_object_get_data(G_OBJECT(item), "user_data"); } static GtkWidget * @@ -148,7 +150,9 @@ gtk_widget_show(vbox); /* Protocol */ - dialog->protocol_menu = __make_protocol_menu(dialog); + dialog->protocol_menu = gaim_gtk_protocol_option_menu_new(-1, + G_CALLBACK(__set_account_protocol), dialog); + __add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu); /* Screen Name */
--- 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; +}
--- a/src/gtkutils.h Sun Jun 01 21:36:40 2003 +0000 +++ b/src/gtkutils.h Sun Jun 01 23:14:31 2003 +0000 @@ -26,6 +26,7 @@ #include "gaim.h" #include "conversation.h" +#include "prpl.h" /** * Sets up a gtkimhtml widget, loads it with smileys, and sets the @@ -163,4 +164,17 @@ */ GtkWidget *gaim_gtk_make_frame(GtkWidget *parent, const char *title); +/** + * Creates a drop-down option menu filled with protocols. + * + * @param protocol The protocol to select by default. + * @param cb The callback to call when a protocol is selected. + * @param user_data Data to pass to the callback function. + * + * @return The drop-down option menu. + */ +GtkWidget *gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, + GCallback cb, + gpointer user_data); + #endif /* _GAIM_GTK_UTILS_H_ */