Mercurial > pidgin
comparison src/dialogs.c @ 3802:9bcb42faccc0
[gaim-migrate @ 3945]
Rewrote show_im_dialog and show_info_dialog.
Ported to gtkspell2. Gtkspell2 is a library available from
gtkspell.sf.net. It requires the pspell library. If you want the
"highlight misspelled words" feature to work, you must have this
library installed. If installed, configure will detect it and link
against it.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Sat, 26 Oct 2002 06:41:13 +0000 |
| parents | 7469dcf5ada5 |
| children | f9775881ea94 |
comparison
equal
deleted
inserted
replaced
| 3801:8cc3d7526043 | 3802:9bcb42faccc0 |
|---|---|
| 557 return d; | 557 return d; |
| 558 } | 558 } |
| 559 | 559 |
| 560 | 560 |
| 561 | 561 |
| 562 static void do_im(GtkWidget *widget, GtkWidget *imentry) | 562 static void do_im(GtkWidget *widget, int resp, GtkWidget *imentry) |
| 563 { | 563 { |
| 564 char *who; | 564 char *who; |
| 565 struct conversation *c; | 565 struct conversation *c; |
| 566 | 566 |
| 567 who = g_strdup(gtk_entry_get_text(GTK_ENTRY(imentry))); | 567 if (resp == GTK_RESPONSE_OK) { |
| 568 destroy_dialog(NULL, imdialog); | 568 who = g_strdup(gtk_entry_get_text(GTK_ENTRY(imentry))); |
| 569 imdialog = NULL; | 569 destroy_dialog(NULL, imdialog); |
| 570 | 570 imdialog = NULL; |
| 571 if (!g_strcasecmp(who, "")) { | 571 |
| 572 if (!g_strcasecmp(who, "")) { | |
| 573 g_free(who); | |
| 574 return; | |
| 575 } | |
| 576 | |
| 577 c = find_conversation(who); | |
| 578 | |
| 579 if (c == NULL) { | |
| 580 c = new_conversation(who); | |
| 581 } else { | |
| 582 gdk_window_raise(c->window->window); | |
| 583 } | |
| 572 g_free(who); | 584 g_free(who); |
| 573 return; | 585 } |
| 574 } | 586 |
| 575 | 587 destroy_dialog(NULL, widget); |
| 576 c = find_conversation(who); | 588 } |
| 577 | 589 |
| 578 if (c == NULL) { | 590 static void do_info(GtkWidget *widget, int resp, struct getuserinfo *info) |
| 579 c = new_conversation(who); | |
| 580 } else { | |
| 581 gdk_window_raise(c->window->window); | |
| 582 } | |
| 583 g_free(who); | |
| 584 } | |
| 585 | |
| 586 static void do_info(GtkWidget *widget, struct getuserinfo *info) | |
| 587 { | 591 { |
| 588 char *who; | 592 char *who; |
| 589 | 593 |
| 590 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(info->entry)))); | 594 if (resp == GTK_RESPONSE_OK) { |
| 591 destroy_dialog(NULL, info->window); | 595 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(info->entry)))); |
| 592 | 596 |
| 593 if (!g_strcasecmp(who, "")) { | 597 if (!g_strcasecmp(who, "")) { |
| 598 g_free(who); | |
| 599 return; | |
| 600 } | |
| 601 | |
| 602 /* what do we want to do about this case? */ | |
| 603 if (info->gc) | |
| 604 serv_get_info(info->gc, who); | |
| 594 g_free(who); | 605 g_free(who); |
| 595 return; | 606 } |
| 596 } | 607 gtk_widget_destroy(GTK_WIDGET(widget)); |
| 597 | |
| 598 /* what do we want to do about this case? */ | |
| 599 if (info->gc) | |
| 600 serv_get_info(info->gc, who); | |
| 601 | |
| 602 g_free(who); | |
| 603 } | 608 } |
| 604 | 609 |
| 605 void show_ee_dialog(int ee) | 610 void show_ee_dialog(int ee) |
| 606 { | 611 { |
| 607 GtkWidget *window; | 612 GtkWidget *window; |
| 661 gtk_widget_show_all(window); | 666 gtk_widget_show_all(window); |
| 662 } | 667 } |
| 663 | 668 |
| 664 void show_im_dialog() | 669 void show_im_dialog() |
| 665 { | 670 { |
| 666 GtkWidget *mainbox; | 671 GtkWidget *hbox, *vbox; |
| 667 GtkWidget *frame; | |
| 668 GtkWidget *fbox; | |
| 669 GtkWidget *bbox; | |
| 670 GtkWidget *button; | |
| 671 GtkWidget *imentry; | |
| 672 GtkWidget *label; | 672 GtkWidget *label; |
| 673 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_question.png", NULL); | |
| 674 GtkWidget *img = gtk_image_new_from_file(filename); | |
| 675 GtkWidget *entry; | |
| 673 | 676 |
| 674 if (!imdialog) { | 677 if (!imdialog) { |
| 675 GAIM_DIALOG(imdialog); | 678 imdialog = gtk_dialog_new_with_buttons("", NULL, GTK_DIALOG_MODAL, |
| 676 gtk_window_set_wmclass(GTK_WINDOW(imdialog), "imdialog", "Gaim"); | 679 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); |
| 677 gtk_window_set_policy(GTK_WINDOW(imdialog), FALSE, TRUE, TRUE); | 680 gtk_dialog_set_default_response (GTK_DIALOG(imdialog), GTK_RESPONSE_OK); |
| 678 gtk_window_set_title(GTK_WINDOW(imdialog), _("Gaim - IM user")); | 681 gtk_container_set_border_width (GTK_CONTAINER(imdialog), 6); |
| 679 gtk_signal_connect(GTK_OBJECT(imdialog), "destroy", | 682 gtk_window_set_resizable(GTK_WINDOW(imdialog), FALSE); |
| 680 GTK_SIGNAL_FUNC(destroy_dialog), imdialog); | 683 gtk_dialog_set_has_separator(GTK_DIALOG(imdialog), FALSE); |
| 681 gtk_widget_realize(imdialog); | 684 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(imdialog)->vbox), 12); |
| 682 | 685 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), 6); |
| 683 mainbox = gtk_vbox_new(FALSE, 5); | 686 |
| 684 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5); | 687 hbox = gtk_hbox_new(FALSE, 12); |
| 685 gtk_container_add(GTK_CONTAINER(imdialog), mainbox); | 688 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), hbox); |
| 686 | 689 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| 687 frame = gtk_frame_new(_("Send Instant Message")); | 690 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
| 688 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0); | 691 |
| 689 | 692 vbox = gtk_vbox_new(FALSE, 0); |
| 690 fbox = gtk_hbox_new(FALSE, 5); | 693 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
| 691 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5); | 694 |
| 692 gtk_container_add(GTK_CONTAINER(frame), fbox); | 695 label = gtk_label_new(_("Please enter the screenname of the person you would like to IM.\n")); |
| 693 | 696 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 694 label = gtk_label_new(_("IM who:")); | 697 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
| 695 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0); | 698 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
| 696 | 699 |
| 697 imentry = gtk_entry_new(); | 700 hbox = gtk_hbox_new(FALSE, 6); |
| 698 gtk_box_pack_start(GTK_BOX(fbox), imentry, TRUE, TRUE, 0); | 701 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
| 699 gtk_signal_connect(GTK_OBJECT(imentry), "activate", GTK_SIGNAL_FUNC(do_im), imentry); | 702 |
| 700 gtk_widget_grab_focus(imentry); | 703 label = gtk_label_new(NULL); |
| 701 | 704 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname")); |
| 702 bbox = gtk_hbox_new(FALSE, 5); | 705 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 703 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); | 706 |
| 704 | 707 entry = gtk_entry_new(); |
| 705 button = picture_button(imdialog, _("Cancel"), cancel_xpm); | 708 gtk_entry_set_activates_default (GTK_ENTRY(entry), TRUE); |
| 706 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 709 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
| 707 gtk_signal_connect(GTK_OBJECT(button), "clicked", | 710 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(entry)); |
| 708 GTK_SIGNAL_FUNC(destroy_dialog), imdialog); | 711 |
| 709 | 712 g_signal_connect(G_OBJECT(imdialog), "response", G_CALLBACK(do_info), entry); |
| 710 button = picture_button(imdialog, _("OK"), ok_xpm); | 713 |
| 711 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 714 dialogwindows = g_list_prepend(dialogwindows, imdialog->window); |
| 712 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_im), imentry); | |
| 713 } | 715 } |
| 714 | 716 |
| 715 gtk_widget_show_all(imdialog); | 717 gtk_widget_show_all(imdialog); |
| 718 if (entry) | |
| 719 gtk_widget_grab_focus(GTK_WIDGET(entry)); | |
| 716 } | 720 } |
| 717 | 721 |
| 718 void show_info_select_account(GtkObject *w, struct gaim_connection *gc) | 722 void show_info_select_account(GtkObject *w, struct gaim_connection *gc) |
| 719 { | 723 { |
| 720 struct getuserinfo *info = gtk_object_get_user_data(w); | 724 struct getuserinfo *info = gtk_object_get_user_data(w); |
| 721 info->gc = gc; | 725 info->gc = gc; |
| 722 } | 726 } |
| 723 | 727 |
| 724 void show_info_dialog() | 728 void show_info_dialog() |
| 725 { | 729 { |
| 726 GtkWidget *mainbox; | 730 GtkWidget *window, *hbox, *vbox; |
| 727 GtkWidget *frame; | |
| 728 GtkWidget *table; | |
| 729 GtkWidget *bbox; | |
| 730 GtkWidget *button; | |
| 731 GtkWidget *label; | 731 GtkWidget *label; |
| 732 GtkWidget *menu, *opt; | 732 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_question.png", NULL); |
| 733 char buf[2048]; | 733 GtkWidget *img = gtk_image_new_from_file(filename); |
| 734 GtkWidget *table, *menu, *opt; | |
| 734 GSList *g = connections; | 735 GSList *g = connections; |
| 735 struct gaim_connection *c; | 736 struct gaim_connection *c; |
| 736 | |
| 737 struct getuserinfo *info = g_new0(struct getuserinfo, 1); | 737 struct getuserinfo *info = g_new0(struct getuserinfo, 1); |
| 738 char buf[256]; | |
| 739 | |
| 738 info->gc = connections->data; | 740 info->gc = connections->data; |
| 739 | 741 |
| 740 GAIM_DIALOG(info->window); | 742 window = gtk_dialog_new_with_buttons("", blist ? GTK_WINDOW(blist) : NULL, GTK_DIALOG_MODAL, |
| 741 gtk_window_set_wmclass(GTK_WINDOW(info->window), "infodialog", "Gaim"); | 743 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); |
| 742 gtk_window_set_policy(GTK_WINDOW(info->window), FALSE, TRUE, TRUE); | 744 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); |
| 743 gtk_widget_realize(info->window); | 745 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
| 744 | 746 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
| 745 mainbox = gtk_vbox_new(FALSE, 5); | 747 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); |
| 746 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5); | 748 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); |
| 747 gtk_container_add(GTK_CONTAINER(info->window), mainbox); | 749 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); |
| 748 | 750 |
| 749 frame = gtk_frame_new(_("Get User Info")); | 751 hbox = gtk_hbox_new(FALSE, 12); |
| 750 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0); | 752 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); |
| 751 | 753 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
| 754 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
| 755 | |
| 756 vbox = gtk_vbox_new(FALSE, 0); | |
| 757 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
| 758 | |
| 759 label = gtk_label_new(_("Please enter the screenname of the person whose info you would like to view.\n")); | |
| 760 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 761 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 762 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 763 | |
| 752 table = gtk_table_new(2, 2, FALSE); | 764 table = gtk_table_new(2, 2, FALSE); |
| 753 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | 765 gtk_table_set_row_spacings(GTK_TABLE(table), 6); |
| 754 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | 766 gtk_table_set_col_spacings(GTK_TABLE(table), 6); |
| 755 gtk_container_set_border_width(GTK_CONTAINER(table), 5); | 767 gtk_container_set_border_width(GTK_CONTAINER(table), 12); |
| 756 gtk_container_add(GTK_CONTAINER(frame), table); | 768 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
| 757 | 769 |
| 758 label = gtk_label_new(_("User:")); | 770 label = gtk_label_new(NULL); |
| 771 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname:")); | |
| 772 gtk_misc_set_alignment(GTK_LABEL(img), 0, 0); | |
| 759 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | 773 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); |
| 760 gtk_widget_show(label); | |
| 761 | 774 |
| 762 info->entry = gtk_entry_new(); | 775 info->entry = gtk_entry_new(); |
| 763 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | 776 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); |
| 764 | 777 gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE); |
| 778 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry)); | |
| 779 | |
| 765 if (connections->next) { | 780 if (connections->next) { |
| 766 | 781 |
| 767 label = gtk_label_new(_("Account:")); | 782 label = gtk_label_new(NULL); |
| 768 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | 783 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
| 769 gtk_widget_show(label); | 784 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:")); |
| 785 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 770 | 786 |
| 771 info->account = gtk_option_menu_new(); | 787 info->account = gtk_option_menu_new(); |
| 772 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); | 788 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); |
| 773 | 789 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account)); |
| 790 | |
| 774 menu = gtk_menu_new(); | 791 menu = gtk_menu_new(); |
| 775 | 792 |
| 776 while (g) { | 793 while (g) { |
| 777 c = (struct gaim_connection *)g->data; | 794 c = (struct gaim_connection *)g->data; |
| 795 if (!c->prpl->get_info) { | |
| 796 g = g->next; | |
| 797 continue; | |
| 798 } | |
| 778 g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name); | 799 g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name); |
| 779 opt = gtk_menu_item_new_with_label(buf); | 800 opt = gtk_menu_item_new_with_label(buf); |
| 780 gtk_object_set_user_data(GTK_OBJECT(opt), info); | 801 gtk_object_set_user_data(GTK_OBJECT(opt), info); |
| 781 | 802 |
| 782 gtk_signal_connect(GTK_OBJECT(opt), "activate", | 803 gtk_signal_connect(GTK_OBJECT(opt), "activate", |
| 783 GTK_SIGNAL_FUNC(show_info_select_account), c); | 804 GTK_SIGNAL_FUNC(show_info_select_account), c); |
| 784 | 805 |
| 785 gtk_menu_append(GTK_MENU(menu), opt); | 806 gtk_menu_append(GTK_MENU(menu), opt); |
| 786 gtk_widget_show(opt); | |
| 787 | |
| 788 g = g->next; | 807 g = g->next; |
| 789 } | 808 } |
| 790 | 809 |
| 791 gtk_widget_show(menu); | |
| 792 gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu); | 810 gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu); |
| 793 gtk_widget_show(info->account); | 811 } |
| 794 } | 812 |
| 795 | 813 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_info), info); |
| 796 /* Handle closes right */ | 814 |
| 797 gtk_signal_connect(GTK_OBJECT(info->entry), "activate", | 815 |
| 798 GTK_SIGNAL_FUNC(do_info), info); | 816 gtk_widget_show_all(window); |
| 799 gtk_signal_connect(GTK_OBJECT(info->window), "destroy", | 817 if (info->entry) |
| 800 GTK_SIGNAL_FUNC(destroy_dialog), info->window); | 818 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); |
| 801 | |
| 802 /* Buttons */ | |
| 803 bbox = gtk_hbox_new(FALSE, 5); | |
| 804 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); | |
| 805 | |
| 806 button = picture_button(info->window, _("Cancel"), cancel_xpm); | |
| 807 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
| 808 gtk_signal_connect(GTK_OBJECT(button), "clicked", | |
| 809 GTK_SIGNAL_FUNC(destroy_dialog), info->window); | |
| 810 | |
| 811 button = picture_button(info->window, _("OK"), ok_xpm); | |
| 812 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
| 813 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), info); | |
| 814 | |
| 815 /* Finish up */ | |
| 816 gtk_window_set_title(GTK_WINDOW(info->window), _("Gaim - Get User Info")); | |
| 817 gtk_widget_grab_focus(info->entry); | |
| 818 | |
| 819 gtk_widget_show_all(info->window); | |
| 820 } | 819 } |
| 821 | 820 |
| 822 | 821 |
| 823 /*------------------------------------------------------------------------*/ | 822 /*------------------------------------------------------------------------*/ |
| 824 /* The dialog for adding buddies */ | 823 /* The dialog for adding buddies */ |
