Mercurial > pidgin.yaz
changeset 5647:6e551616d051
[gaim-migrate @ 6061]
The callbacks on our protocols menu are now a lot less wasteful.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 02 Jun 2003 04:52:59 +0000 |
parents | 48c63ee49961 |
children | 0cc2d99b7c44 |
files | src/gtkutils.c |
diffstat | 1 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkutils.c Mon Jun 02 03:52:43 2003 +0000 +++ b/src/gtkutils.c Mon Jun 02 04:52:59 2003 +0000 @@ -523,6 +523,25 @@ return vbox; } +static void +__protocol_menu_cb(GtkWidget *optmenu, GCallback cb) +{ + GtkWidget *menu; + GtkWidget *item; + GaimProtocol protocol; + gpointer user_data; + + menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); + item = gtk_menu_get_active(GTK_MENU(menu)); + + protocol = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "protocol")); + user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); + + if (cb != NULL) + ((void (*)(GtkWidget *, GaimProtocol, gpointer))cb)(item, protocol, + user_data); +} + GtkWidget * gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, gpointer user_data) @@ -544,9 +563,14 @@ optmenu = gtk_option_menu_new(); gtk_widget_show(optmenu); + g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); + menu = gtk_menu_new(); gtk_widget_show(menu); + g_signal_connect(G_OBJECT(optmenu), "changed", + G_CALLBACK(__protocol_menu_cb), cb); + for (p = gaim_plugins_get_protocols(), i = 0; p != NULL; p = p->next, i++) { @@ -577,10 +601,8 @@ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); } - 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)); + g_object_set_data(G_OBJECT(item), "protocol", + GINT_TO_POINTER(prpl_info->protocol)); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); gtk_widget_show(item);