Mercurial > pidgin.yaz
comparison src/dialogs.c @ 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 | fce1883cc608 |
children | 5456065a16a8 |
comparison
equal
deleted
inserted
replaced
3196:8b3d16785480 | 3197:389ed797f396 |
---|---|
88 char *current_smiley; | 88 char *current_smiley; |
89 GdkColor bgcolor; | 89 GdkColor bgcolor; |
90 GdkColor fgcolor; | 90 GdkColor fgcolor; |
91 | 91 |
92 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ | 92 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ |
93 static GtkWidget *infodialog = NULL; | |
94 static GList *dialogwindows = NULL; | 93 static GList *dialogwindows = NULL; |
95 static GtkWidget *importdialog; | 94 static GtkWidget *importdialog; |
96 static struct gaim_connection *importgc; | 95 static struct gaim_connection *importgc; |
97 static GtkWidget *icondlg; | 96 static GtkWidget *icondlg; |
98 static GtkWidget *aliasdlg = NULL; | 97 static GtkWidget *aliasdlg = NULL; |
184 struct gaim_connection *gc; | 183 struct gaim_connection *gc; |
185 char *who; | 184 char *who; |
186 GtkWidget *window; | 185 GtkWidget *window; |
187 GtkWidget *text; | 186 GtkWidget *text; |
188 }; | 187 }; |
188 | |
189 struct getuserinfo { | |
190 GtkWidget *window; | |
191 GtkWidget *entry; | |
192 GtkWidget *account; | |
193 struct gaim_connection *gc; | |
194 }; | |
195 | |
189 static GSList *info_dlgs = NULL; | 196 static GSList *info_dlgs = NULL; |
190 | 197 |
191 static struct info_dlg *find_info_dlg(struct gaim_connection *gc, char *who) | 198 static struct info_dlg *find_info_dlg(struct gaim_connection *gc, char *who) |
192 { | 199 { |
193 GSList *i = info_dlgs; | 200 GSList *i = info_dlgs; |
319 dest = w2; | 326 dest = w2; |
320 | 327 |
321 if (dest == imdialog) | 328 if (dest == imdialog) |
322 imdialog = NULL; | 329 imdialog = NULL; |
323 | 330 |
324 if (dest == infodialog) | |
325 infodialog = NULL; | |
326 | |
327 if (dest == importdialog) { | 331 if (dest == importdialog) { |
328 importdialog = NULL; | 332 importdialog = NULL; |
329 importgc = NULL; | 333 importgc = NULL; |
330 } | 334 } |
331 | 335 |
359 do_im_back(NULL, NULL); | 363 do_im_back(NULL, NULL); |
360 | 364 |
361 if (imdialog) { | 365 if (imdialog) { |
362 destroy_dialog(NULL, imdialog); | 366 destroy_dialog(NULL, imdialog); |
363 imdialog = NULL; | 367 imdialog = NULL; |
364 } | |
365 | |
366 if (infodialog) { | |
367 destroy_dialog(NULL, infodialog); | |
368 infodialog = NULL; | |
369 } | 368 } |
370 | 369 |
371 if (importdialog) { | 370 if (importdialog) { |
372 destroy_dialog(NULL, importdialog); | 371 destroy_dialog(NULL, importdialog); |
373 importdialog = NULL; | 372 importdialog = NULL; |
603 gdk_window_raise(c->window->window); | 602 gdk_window_raise(c->window->window); |
604 } | 603 } |
605 g_free(who); | 604 g_free(who); |
606 } | 605 } |
607 | 606 |
608 static void do_info(GtkWidget *widget, GtkWidget *infoentry) | 607 static void do_info(GtkWidget *widget, struct getuserinfo *info) |
609 { | 608 { |
610 char *who; | 609 char *who; |
611 | 610 |
612 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(infoentry)))); | 611 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(info->entry)))); |
613 destroy_dialog(NULL, infodialog); | 612 destroy_dialog(NULL, info->window); |
614 infodialog = NULL; | |
615 | 613 |
616 if (!g_strcasecmp(who, "")) { | 614 if (!g_strcasecmp(who, "")) { |
617 g_free(who); | 615 g_free(who); |
618 return; | 616 return; |
619 } | 617 } |
620 | 618 |
621 /* what do we want to do about this case? */ | 619 /* what do we want to do about this case? */ |
622 if (connections) | 620 if (info->gc) |
623 serv_get_info(connections->data, who); | 621 serv_get_info(info->gc, who); |
624 | 622 |
625 g_free(who); | 623 g_free(who); |
626 } | 624 } |
627 | 625 |
628 void show_ee_dialog(int ee) | 626 void show_ee_dialog(int ee) |
725 } | 723 } |
726 | 724 |
727 gtk_widget_show_all(imdialog); | 725 gtk_widget_show_all(imdialog); |
728 } | 726 } |
729 | 727 |
728 void show_info_select_account(GtkObject *w, struct gaim_connection *gc) | |
729 { | |
730 struct getuserinfo *info = gtk_object_get_user_data(w); | |
731 info->gc = gc; | |
732 } | |
733 | |
730 void show_info_dialog() | 734 void show_info_dialog() |
731 { | 735 { |
732 GtkWidget *mainbox; | 736 GtkWidget *mainbox; |
733 GtkWidget *frame; | 737 GtkWidget *frame; |
734 GtkWidget *fbox; | 738 GtkWidget *table; |
735 GtkWidget *bbox; | 739 GtkWidget *bbox; |
736 GtkWidget *button; | 740 GtkWidget *button; |
737 GtkWidget *infoentry; | |
738 GtkWidget *label; | 741 GtkWidget *label; |
739 | 742 GtkWidget *menu, *opt; |
740 if (!infodialog) { | 743 char buf[2048]; |
741 | 744 GSList *g = connections; |
742 GAIM_DIALOG(infodialog); | 745 struct gaim_connection *c; |
743 gtk_window_set_wmclass(GTK_WINDOW(infodialog), "infodialog", "Gaim"); | 746 |
744 gtk_window_set_policy(GTK_WINDOW(infodialog), FALSE, TRUE, TRUE); | 747 struct getuserinfo *info = g_new0(struct getuserinfo, 1); |
745 gtk_widget_realize(infodialog); | 748 info->gc = connections->data; |
746 | 749 |
747 mainbox = gtk_vbox_new(FALSE, 5); | 750 GAIM_DIALOG(info->window); |
748 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5); | 751 gtk_window_set_wmclass(GTK_WINDOW(info->window), "infodialog", "Gaim"); |
749 gtk_container_add(GTK_CONTAINER(infodialog), mainbox); | 752 gtk_window_set_policy(GTK_WINDOW(info->window), FALSE, TRUE, TRUE); |
750 | 753 gtk_widget_realize(info->window); |
751 frame = gtk_frame_new(_("Get User Info")); | 754 |
752 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0); | 755 mainbox = gtk_vbox_new(FALSE, 5); |
753 | 756 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5); |
754 fbox = gtk_hbox_new(FALSE, 5); | 757 gtk_container_add(GTK_CONTAINER(info->window), mainbox); |
755 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5); | 758 |
756 gtk_container_add(GTK_CONTAINER(frame), fbox); | 759 frame = gtk_frame_new(_("Get User Info")); |
757 | 760 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0); |
758 label = gtk_label_new(_("User:")); | 761 |
759 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0); | 762 table = gtk_table_new(2, 2, FALSE); |
763 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | |
764 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | |
765 gtk_container_set_border_width(GTK_CONTAINER(table), 5); | |
766 gtk_container_add(GTK_CONTAINER(frame), table); | |
767 | |
768 label = gtk_label_new(_("User:")); | |
769 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
770 gtk_widget_show(label); | |
771 | |
772 info->entry = gtk_entry_new(); | |
773 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
774 | |
775 if (connections->next) { | |
776 | |
777 label = gtk_label_new(_("Account:")); | |
778 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
760 gtk_widget_show(label); | 779 gtk_widget_show(label); |
761 | 780 |
762 infoentry = gtk_entry_new(); | 781 info->account = gtk_option_menu_new(); |
763 gtk_box_pack_start(GTK_BOX(fbox), infoentry, TRUE, TRUE, 0); | 782 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); |
764 | 783 |
765 /* Handle closes right */ | 784 menu = gtk_menu_new(); |
766 gtk_signal_connect(GTK_OBJECT(infoentry), "activate", | 785 |
767 GTK_SIGNAL_FUNC(do_info), infoentry); | 786 while (g) { |
768 gtk_signal_connect(GTK_OBJECT(infodialog), "destroy", | 787 c = (struct gaim_connection *)g->data; |
769 GTK_SIGNAL_FUNC(destroy_dialog), infodialog); | 788 g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name()); |
770 | 789 opt = gtk_menu_item_new_with_label(buf); |
771 /* Buttons */ | 790 gtk_object_set_user_data(GTK_OBJECT(opt), info); |
772 bbox = gtk_hbox_new(FALSE, 5); | 791 |
773 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); | 792 gtk_signal_connect(GTK_OBJECT(opt), "activate", |
774 | 793 GTK_SIGNAL_FUNC(show_info_select_account), c); |
775 button = picture_button(infodialog, _("Cancel"), cancel_xpm); | 794 |
776 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 795 gtk_menu_append(GTK_MENU(menu), opt); |
777 gtk_signal_connect(GTK_OBJECT(button), "clicked", | 796 gtk_widget_show(opt); |
778 GTK_SIGNAL_FUNC(destroy_dialog), infodialog); | 797 |
779 | 798 g = g->next; |
780 button = picture_button(infodialog, _("OK"), ok_xpm); | 799 } |
781 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 800 |
782 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), infoentry); | 801 gtk_widget_show(menu); |
783 | 802 gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu); |
784 /* Finish up */ | 803 gtk_widget_show(info->account); |
785 gtk_window_set_title(GTK_WINDOW(infodialog), _("Gaim - Get User Info")); | 804 } |
786 gtk_widget_grab_focus(infoentry); | 805 |
787 | 806 /* Handle closes right */ |
788 aol_icon(infodialog->window); | 807 gtk_signal_connect(GTK_OBJECT(info->entry), "activate", |
789 } | 808 GTK_SIGNAL_FUNC(do_info), info); |
790 gtk_widget_show_all(infodialog); | 809 gtk_signal_connect(GTK_OBJECT(info->window), "destroy", |
810 GTK_SIGNAL_FUNC(destroy_dialog), info->window); | |
811 | |
812 /* Buttons */ | |
813 bbox = gtk_hbox_new(FALSE, 5); | |
814 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); | |
815 | |
816 button = picture_button(info->window, _("Cancel"), cancel_xpm); | |
817 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
818 gtk_signal_connect(GTK_OBJECT(button), "clicked", | |
819 GTK_SIGNAL_FUNC(destroy_dialog), info->window); | |
820 | |
821 button = picture_button(info->window, _("OK"), ok_xpm); | |
822 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
823 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), info); | |
824 | |
825 /* Finish up */ | |
826 gtk_window_set_title(GTK_WINDOW(info->window), _("Gaim - Get User Info")); | |
827 gtk_widget_grab_focus(info->entry); | |
828 | |
829 aol_icon(info->window->window); | |
830 gtk_widget_show_all(info->window); | |
791 } | 831 } |
792 | 832 |
793 | 833 |
794 /*------------------------------------------------------------------------*/ | 834 /*------------------------------------------------------------------------*/ |
795 /* The dialog for adding buddies */ | 835 /* The dialog for adding buddies */ |