Mercurial > pidgin
changeset 3197:389ed797f396
[gaim-migrate @ 3214]
click81's patch for get_info from the menu.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Fri, 03 May 2002 19:46:07 +0000 |
parents | 8b3d16785480 |
children | ccf5cd2f0354 |
files | ChangeLog src/dialogs.c |
diffstat | 2 files changed, 108 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri May 03 19:24:19 2002 +0000 +++ b/ChangeLog Fri May 03 19:46:07 2002 +0000 @@ -6,6 +6,8 @@ * Better applet transparency * Option to raise buddy list on signons/signoffs * Formatting of incoming MSN messages + * Get Info from menu multiple-account-aware (thanks + Brian Bernas) version 0.57 (04/25/2002): * New authorization method for Yahoo!
--- a/src/dialogs.c Fri May 03 19:24:19 2002 +0000 +++ b/src/dialogs.c Fri May 03 19:46:07 2002 +0000 @@ -90,7 +90,6 @@ GdkColor fgcolor; static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ -static GtkWidget *infodialog = NULL; static GList *dialogwindows = NULL; static GtkWidget *importdialog; static struct gaim_connection *importgc; @@ -186,6 +185,14 @@ GtkWidget *window; GtkWidget *text; }; + +struct getuserinfo { + GtkWidget *window; + GtkWidget *entry; + GtkWidget *account; + struct gaim_connection *gc; +}; + static GSList *info_dlgs = NULL; static struct info_dlg *find_info_dlg(struct gaim_connection *gc, char *who) @@ -321,9 +328,6 @@ if (dest == imdialog) imdialog = NULL; - if (dest == infodialog) - infodialog = NULL; - if (dest == importdialog) { importdialog = NULL; importgc = NULL; @@ -363,11 +367,6 @@ imdialog = NULL; } - if (infodialog) { - destroy_dialog(NULL, infodialog); - infodialog = NULL; - } - if (importdialog) { destroy_dialog(NULL, importdialog); importdialog = NULL; @@ -605,13 +604,12 @@ g_free(who); } -static void do_info(GtkWidget *widget, GtkWidget *infoentry) +static void do_info(GtkWidget *widget, struct getuserinfo *info) { char *who; - who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(infoentry)))); - destroy_dialog(NULL, infodialog); - infodialog = NULL; + who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(info->entry)))); + destroy_dialog(NULL, info->window); if (!g_strcasecmp(who, "")) { g_free(who); @@ -619,8 +617,8 @@ } /* what do we want to do about this case? */ - if (connections) - serv_get_info(connections->data, who); + if (info->gc) + serv_get_info(info->gc, who); g_free(who); } @@ -727,67 +725,109 @@ gtk_widget_show_all(imdialog); } +void show_info_select_account(GtkObject *w, struct gaim_connection *gc) +{ + struct getuserinfo *info = gtk_object_get_user_data(w); + info->gc = gc; +} + void show_info_dialog() { GtkWidget *mainbox; GtkWidget *frame; - GtkWidget *fbox; + GtkWidget *table; GtkWidget *bbox; GtkWidget *button; - GtkWidget *infoentry; GtkWidget *label; - - if (!infodialog) { - - GAIM_DIALOG(infodialog); - gtk_window_set_wmclass(GTK_WINDOW(infodialog), "infodialog", "Gaim"); - gtk_window_set_policy(GTK_WINDOW(infodialog), FALSE, TRUE, TRUE); - gtk_widget_realize(infodialog); - - mainbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5); - gtk_container_add(GTK_CONTAINER(infodialog), mainbox); - - frame = gtk_frame_new(_("Get User Info")); - gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0); - - fbox = gtk_hbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(fbox), 5); - gtk_container_add(GTK_CONTAINER(frame), fbox); - - label = gtk_label_new(_("User:")); - gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0); + GtkWidget *menu, *opt; + char buf[2048]; + GSList *g = connections; + struct gaim_connection *c; + + struct getuserinfo *info = g_new0(struct getuserinfo, 1); + info->gc = connections->data; + + GAIM_DIALOG(info->window); + gtk_window_set_wmclass(GTK_WINDOW(info->window), "infodialog", "Gaim"); + gtk_window_set_policy(GTK_WINDOW(info->window), FALSE, TRUE, TRUE); + gtk_widget_realize(info->window); + + mainbox = gtk_vbox_new(FALSE, 5); + gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5); + gtk_container_add(GTK_CONTAINER(info->window), mainbox); + + frame = gtk_frame_new(_("Get User Info")); + gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0); + + table = gtk_table_new(2, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(table), 5); + gtk_table_set_col_spacings(GTK_TABLE(table), 5); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + gtk_container_add(GTK_CONTAINER(frame), table); + + label = gtk_label_new(_("User:")); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); + gtk_widget_show(label); + + info->entry = gtk_entry_new(); + gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); + + if (connections->next) { + + label = gtk_label_new(_("Account:")); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); gtk_widget_show(label); - infoentry = gtk_entry_new(); - gtk_box_pack_start(GTK_BOX(fbox), infoentry, TRUE, TRUE, 0); - - /* Handle closes right */ - gtk_signal_connect(GTK_OBJECT(infoentry), "activate", - GTK_SIGNAL_FUNC(do_info), infoentry); - gtk_signal_connect(GTK_OBJECT(infodialog), "destroy", - GTK_SIGNAL_FUNC(destroy_dialog), infodialog); - - /* Buttons */ - bbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); - - button = picture_button(infodialog, _("Cancel"), cancel_xpm); - gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(destroy_dialog), infodialog); - - button = picture_button(infodialog, _("OK"), ok_xpm); - gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), infoentry); - - /* Finish up */ - gtk_window_set_title(GTK_WINDOW(infodialog), _("Gaim - Get User Info")); - gtk_widget_grab_focus(infoentry); - - aol_icon(infodialog->window); + info->account = gtk_option_menu_new(); + gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); + + menu = gtk_menu_new(); + + while (g) { + c = (struct gaim_connection *)g->data; + g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name()); + opt = gtk_menu_item_new_with_label(buf); + gtk_object_set_user_data(GTK_OBJECT(opt), info); + + gtk_signal_connect(GTK_OBJECT(opt), "activate", + GTK_SIGNAL_FUNC(show_info_select_account), c); + + gtk_menu_append(GTK_MENU(menu), opt); + gtk_widget_show(opt); + + g = g->next; + } + + gtk_widget_show(menu); + gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu); + gtk_widget_show(info->account); } - gtk_widget_show_all(infodialog); + + /* Handle closes right */ + gtk_signal_connect(GTK_OBJECT(info->entry), "activate", + GTK_SIGNAL_FUNC(do_info), info); + gtk_signal_connect(GTK_OBJECT(info->window), "destroy", + GTK_SIGNAL_FUNC(destroy_dialog), info->window); + + /* Buttons */ + bbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); + + button = picture_button(info->window, _("Cancel"), cancel_xpm); + gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(destroy_dialog), info->window); + + button = picture_button(info->window, _("OK"), ok_xpm); + gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), info); + + /* Finish up */ + gtk_window_set_title(GTK_WINDOW(info->window), _("Gaim - Get User Info")); + gtk_widget_grab_focus(info->entry); + + aol_icon(info->window->window); + gtk_widget_show_all(info->window); }