Mercurial > pidgin.yaz
comparison src/dialogs.c @ 7755:8ebd9038ef62
[gaim-migrate @ 8400]
Code cleanup
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 05 Dec 2003 04:03:31 +0000 |
parents | d691cb95ee67 |
children | 17deab169114 |
comparison
equal
deleted
inserted
replaced
7754:f75991b27e94 | 7755:8ebd9038ef62 |
---|---|
39 #include "ui.h" | 39 #include "ui.h" |
40 | 40 |
41 /* XXX */ | 41 /* XXX */ |
42 #include "gaim.h" | 42 #include "gaim.h" |
43 | 43 |
44 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ | |
45 static GList *dialogwindows = NULL; | 44 static GList *dialogwindows = NULL; |
46 static GtkWidget *importdialog; | |
47 static GaimConnection *importgc; | |
48 static GtkWidget *icondlg; | |
49 static GtkWidget *rename_dialog = NULL; | |
50 static GtkWidget *fontseld = NULL; | 45 static GtkWidget *fontseld = NULL; |
51 | |
52 | 46 |
53 struct confirm_del { | 47 struct confirm_del { |
54 GtkWidget *window; | 48 GtkWidget *window; |
55 GtkWidget *label; | 49 GtkWidget *label; |
56 GtkWidget *ok; | 50 GtkWidget *ok; |
239 if (!GTK_IS_WIDGET(w2)) | 233 if (!GTK_IS_WIDGET(w2)) |
240 dest = w; | 234 dest = w; |
241 else | 235 else |
242 dest = w2; | 236 dest = w2; |
243 | 237 |
244 if (dest == imdialog) | |
245 imdialog = NULL; | |
246 else if (dest == importdialog) { | |
247 importdialog = NULL; | |
248 importgc = NULL; | |
249 } | |
250 else if (dest == icondlg) | |
251 icondlg = NULL; | |
252 else if (dest == rename_dialog) | |
253 rename_dialog = NULL; | |
254 | |
255 dialogwindows = g_list_remove(dialogwindows, dest); | 238 dialogwindows = g_list_remove(dialogwindows, dest); |
256 gtk_widget_destroy(dest); | 239 gtk_widget_destroy(dest); |
257 } | 240 } |
258 | 241 |
259 | 242 |
262 while (dialogwindows) | 245 while (dialogwindows) |
263 destroy_dialog(NULL, dialogwindows->data); | 246 destroy_dialog(NULL, dialogwindows->data); |
264 | 247 |
265 if (awaymessage) | 248 if (awaymessage) |
266 do_im_back(NULL, NULL); | 249 do_im_back(NULL, NULL); |
267 | |
268 if (imdialog) { | |
269 destroy_dialog(NULL, imdialog); | |
270 imdialog = NULL; | |
271 } | |
272 | |
273 if (importdialog) { | |
274 destroy_dialog(NULL, importdialog); | |
275 importdialog = NULL; | |
276 } | |
277 | |
278 if (icondlg) { | |
279 destroy_dialog(NULL, icondlg); | |
280 icondlg = NULL; | |
281 } | |
282 } | 250 } |
283 | 251 |
284 static void do_warn(GtkWidget *widget, gint resp, struct warning *w) | 252 static void do_warn(GtkWidget *widget, gint resp, struct warning *w) |
285 { | 253 { |
286 if (resp == GTK_RESPONSE_OK) | 254 if (resp == GTK_RESPONSE_OK) |
509 } | 477 } |
510 | 478 |
511 /*------------------------------------------------------------------------*/ | 479 /*------------------------------------------------------------------------*/ |
512 /* The dialog for getting an error */ | 480 /* The dialog for getting an error */ |
513 /*------------------------------------------------------------------------*/ | 481 /*------------------------------------------------------------------------*/ |
514 static void do_im(GtkWidget *widget, int resp, struct getuserinfo *info) | 482 static void do_im(GtkWidget *dialog, int id, struct getuserinfo *info) |
515 { | 483 { |
516 const char *who; | 484 const char *who; |
517 GaimConversation *conv; | 485 GaimConversation *conv; |
518 GaimAccount *account; | 486 GaimAccount *account; |
519 | 487 |
520 if (resp == GTK_RESPONSE_OK) { | 488 switch(id) { |
489 case GTK_RESPONSE_OK: | |
521 who = gtk_entry_get_text(GTK_ENTRY(info->entry)); | 490 who = gtk_entry_get_text(GTK_ENTRY(info->entry)); |
522 | 491 |
523 if (!who || !*who) { | 492 if (!who || !*who) { |
524 /* this shouldn't ever happen */ | 493 /* this shouldn't ever happen */ |
525 return; | 494 return; |
529 | 498 |
530 conv = gaim_find_conversation_with_account(who, account); | 499 conv = gaim_find_conversation_with_account(who, account); |
531 | 500 |
532 if (conv == NULL) | 501 if (conv == NULL) |
533 conv = gaim_conversation_new(GAIM_CONV_IM, account, who); | 502 conv = gaim_conversation_new(GAIM_CONV_IM, account, who); |
534 else { | 503 else |
535 gaim_conv_window_raise(gaim_conversation_get_window(conv)); | 504 gaim_conv_window_raise(gaim_conversation_get_window(conv)); |
536 } | 505 break; |
537 } | 506 } |
538 | 507 |
539 destroy_dialog(NULL, imdialog); | 508 gtk_widget_destroy(GTK_WIDGET(dialog)); |
540 imdialog = NULL; | |
541 g_free(info); | 509 g_free(info); |
542 } | 510 } |
543 | 511 |
544 static void do_info(GtkWidget *widget, int resp, struct getuserinfo *info) | 512 static void do_info(GtkWidget *dialog, int id, struct getuserinfo *info) |
545 { | 513 { |
546 char *who; | 514 char *who; |
547 | 515 |
548 if (resp == GTK_RESPONSE_OK) { | 516 switch(id) { |
517 case GTK_RESPONSE_OK: | |
549 who = g_strdup(gaim_normalize(info->gc->account, gtk_entry_get_text(GTK_ENTRY(info->entry)))); | 518 who = g_strdup(gaim_normalize(info->gc->account, gtk_entry_get_text(GTK_ENTRY(info->entry)))); |
550 | 519 |
551 if (!g_ascii_strcasecmp(who, "")) { | 520 if (!g_ascii_strcasecmp(who, "")) { |
552 g_free(who); | 521 g_free(who); |
553 return; | 522 return; |
555 | 524 |
556 /* what do we want to do about this case? */ | 525 /* what do we want to do about this case? */ |
557 if (info->gc) | 526 if (info->gc) |
558 serv_get_info(info->gc, who); | 527 serv_get_info(info->gc, who); |
559 g_free(who); | 528 g_free(who); |
560 } | 529 break; |
561 gtk_widget_destroy(GTK_WIDGET(widget)); | 530 } |
531 | |
532 gtk_widget_destroy(GTK_WIDGET(dialog)); | |
562 g_free(info); | 533 g_free(info); |
563 } | 534 } |
564 | 535 |
565 void show_ee_dialog(int ee) | 536 void show_ee_dialog(int ee) |
566 { | 537 { |
629 info->gc = gaim_account_get_connection(account); | 600 info->gc = gaim_account_get_connection(account); |
630 } | 601 } |
631 | 602 |
632 void show_im_dialog() | 603 void show_im_dialog() |
633 { | 604 { |
634 GtkWidget *hbox, *vbox; | 605 GtkWidget *window, *hbox, *vbox; |
635 GtkWidget *label; | 606 GtkWidget *label; |
636 GtkWidget *table; | 607 GtkWidget *table; |
637 GaimGtkBuddyList *gtkblist; | 608 GaimGtkBuddyList *gtkblist; |
638 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); | 609 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
639 struct getuserinfo *info = NULL; | 610 struct getuserinfo *info = g_new0(struct getuserinfo, 1); |
640 | 611 |
641 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | 612 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
642 | 613 |
643 if (!imdialog) { | 614 info->gc = gaim_connections_get_all()->data; |
644 info = g_new0(struct getuserinfo, 1); | 615 |
645 info->gc = gaim_connections_get_all()->data; | 616 window = gtk_dialog_new_with_buttons(_("New Message"), gtkblist ? GTK_WINDOW(gtkblist->window) : NULL, 0, |
646 imdialog = gtk_dialog_new_with_buttons(_("New Message"), gtkblist ? GTK_WINDOW(gtkblist->window) : NULL, 0, | 617 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); |
647 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); | 618 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); |
648 gtk_dialog_set_default_response (GTK_DIALOG(imdialog), GTK_RESPONSE_OK); | 619 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
649 gtk_container_set_border_width (GTK_CONTAINER(imdialog), 6); | 620 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
650 gtk_window_set_resizable(GTK_WINDOW(imdialog), FALSE); | 621 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); |
651 gtk_dialog_set_has_separator(GTK_DIALOG(imdialog), FALSE); | 622 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); |
652 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(imdialog)->vbox), 12); | 623 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); |
653 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), 6); | 624 gtk_dialog_set_response_sensitive(GTK_DIALOG(window), GTK_RESPONSE_OK, FALSE); |
654 gtk_dialog_set_response_sensitive(GTK_DIALOG(imdialog), GTK_RESPONSE_OK, FALSE); | 625 |
655 | 626 hbox = gtk_hbox_new(FALSE, 12); |
656 hbox = gtk_hbox_new(FALSE, 12); | 627 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); |
657 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), hbox); | 628 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
658 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 629 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
659 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | 630 |
660 | 631 vbox = gtk_vbox_new(FALSE, 0); |
661 vbox = gtk_vbox_new(FALSE, 0); | 632 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
662 gtk_container_add(GTK_CONTAINER(hbox), vbox); | 633 |
663 | 634 label = gtk_label_new(_("Please enter the screenname of the person you would like to IM.\n")); |
664 label = gtk_label_new(_("Please enter the screenname of the person you would like to IM.\n")); | 635 gtk_widget_set_size_request(GTK_WIDGET(label), 350, -1); |
665 gtk_widget_set_size_request(GTK_WIDGET(label), 350, -1); | 636 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
666 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 637 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
638 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
639 | |
640 table = gtk_table_new(2, 2, FALSE); | |
641 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
642 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
643 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
644 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
645 | |
646 label = gtk_label_new(NULL); | |
647 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname:")); | |
648 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
649 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
650 | |
651 info->entry = gtk_entry_new(); | |
652 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
653 gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE); | |
654 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry)); | |
655 | |
656 g_signal_connect(G_OBJECT(info->entry), "changed", | |
657 G_CALLBACK(gaim_gtk_set_sensitive_if_input), window); | |
658 | |
659 if (gaim_connections_get_all()->next) { | |
660 | |
661 label = gtk_label_new(NULL); | |
662 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
663 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:")); | |
667 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | 664 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
668 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | 665 |
669 | 666 info->account = gaim_gtk_account_option_menu_new(NULL, FALSE, |
670 hbox = gtk_hbox_new(FALSE, 6); | 667 G_CALLBACK(show_info_select_account), NULL, info); |
671 gtk_container_add(GTK_CONTAINER(vbox), hbox); | 668 |
672 | 669 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); |
673 table = gtk_table_new(2, 2, FALSE); | 670 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account)); |
674 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | 671 } |
675 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | 672 |
676 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | 673 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_im), info); |
677 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | 674 |
678 | 675 gtk_widget_show_all(window); |
679 label = gtk_label_new(NULL); | 676 // if (info->entry) |
680 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname:")); | |
681 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
682 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
683 | |
684 info->entry = gtk_entry_new(); | |
685 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
686 gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE); | |
687 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry)); | |
688 g_signal_connect(G_OBJECT(info->entry), "changed", | |
689 G_CALLBACK(gaim_gtk_set_sensitive_if_input), imdialog); | |
690 | |
691 if (gaim_connections_get_all()->next) { | |
692 | |
693 label = gtk_label_new(NULL); | |
694 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
695 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:")); | |
696 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
697 | |
698 info->account = gaim_gtk_account_option_menu_new(NULL, FALSE, | |
699 G_CALLBACK(show_info_select_account), NULL, info); | |
700 | |
701 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); | |
702 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account)); | |
703 } | |
704 | |
705 g_signal_connect(G_OBJECT(imdialog), "response", G_CALLBACK(do_im), info); | |
706 } | |
707 | |
708 gtk_widget_show_all(imdialog); | |
709 if (info) | |
710 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); | 677 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); |
711 } | 678 } |
712 | 679 |
713 void show_info_dialog() | 680 void show_info_dialog() |
714 { | 681 { |
715 GtkWidget *window, *hbox, *vbox; | 682 GtkWidget *window, *hbox, *vbox; |
716 GtkWidget *label; | 683 GtkWidget *label; |
684 GtkWidget *table; | |
685 GaimGtkBuddyList *gtkblist; | |
717 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); | 686 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
718 GtkWidget *table; | |
719 struct getuserinfo *info = g_new0(struct getuserinfo, 1); | 687 struct getuserinfo *info = g_new0(struct getuserinfo, 1); |
720 GaimGtkBuddyList *gtkblist; | |
721 | 688 |
722 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | 689 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
723 | 690 |
724 info->gc = gaim_connections_get_all()->data; | 691 info->gc = gaim_connections_get_all()->data; |
725 | 692 |
729 gtk_container_set_border_width (GTK_CONTAINER(window), 6); | 696 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
730 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | 697 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
731 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); | 698 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); |
732 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); | 699 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); |
733 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); | 700 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); |
701 gtk_dialog_set_response_sensitive(GTK_DIALOG(window), GTK_RESPONSE_OK, FALSE); | |
734 | 702 |
735 hbox = gtk_hbox_new(FALSE, 12); | 703 hbox = gtk_hbox_new(FALSE, 12); |
736 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); | 704 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); |
737 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 705 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
738 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | 706 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
739 gtk_dialog_set_response_sensitive(GTK_DIALOG(window), GTK_RESPONSE_OK, | |
740 FALSE); | |
741 | 707 |
742 vbox = gtk_vbox_new(FALSE, 0); | 708 vbox = gtk_vbox_new(FALSE, 0); |
743 gtk_container_add(GTK_CONTAINER(hbox), vbox); | 709 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
744 | 710 |
745 label = gtk_label_new(_("Please enter the screenname of the person whose info you would like to view.\n")); | 711 label = gtk_label_new(_("Please enter the screenname of the person whose info you would like to view.\n")); |
780 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account)); | 746 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account)); |
781 } | 747 } |
782 | 748 |
783 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_info), info); | 749 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_info), info); |
784 | 750 |
785 | |
786 gtk_widget_show_all(window); | 751 gtk_widget_show_all(window); |
787 if (info->entry) | 752 // if (info->entry) |
788 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); | 753 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); |
789 } | 754 } |
790 | 755 |
791 | 756 |
792 static void | 757 static void |