comparison src/dialogs.c @ 4613:5385b3625a72

[gaim-migrate @ 4902] this fixes it for real ;-) committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 25 Feb 2003 17:11:01 +0000
parents 71b27122c8a6
children 9f92925b6507
comparison
equal deleted inserted replaced
4612:c05e6ecdc902 4613:5385b3625a72
564 struct gaim_account *account; 564 struct gaim_account *account;
565 565
566 if (resp == GTK_RESPONSE_OK) { 566 if (resp == GTK_RESPONSE_OK) {
567 who = gtk_entry_get_text(GTK_ENTRY(info->entry)); 567 who = gtk_entry_get_text(GTK_ENTRY(info->entry));
568 568
569 if (!g_strcasecmp(who, "")) { 569 if (!who || !*who) {
570 /* 570 /* this shouldn't ever happen */
571 SOMEONE FIX THIS CORRECTLY
572 g_free(info);
573 */
574 return; 571 return;
575 } 572 }
576 573
577 account = (info->gc ? info->gc->account : NULL); 574 account = (info->gc ? info->gc->account : NULL);
578 575
677 { 674 {
678 struct getuserinfo *info = gtk_object_get_user_data(w); 675 struct getuserinfo *info = gtk_object_get_user_data(w);
679 info->gc = gc; 676 info->gc = gc;
680 } 677 }
681 678
679 static void im_dialog_set_ok_sensitive(GtkWidget *entry, gpointer data) {
680 const char *txt = gtk_entry_get_text(GTK_ENTRY(entry));
681 gtk_dialog_set_response_sensitive(GTK_DIALOG(imdialog), GTK_RESPONSE_OK,
682 (*txt != '\0'));
683 }
684
682 void show_im_dialog() 685 void show_im_dialog()
683 { 686 {
684 GtkWidget *hbox, *vbox; 687 GtkWidget *hbox, *vbox;
685 GtkWidget *label; 688 GtkWidget *label;
686 GtkWidget *table, *menu, *opt; 689 GtkWidget *table, *menu, *opt;
694 g_free(filename); 697 g_free(filename);
695 698
696 if (!imdialog) { 699 if (!imdialog) {
697 info = g_new0(struct getuserinfo, 1); 700 info = g_new0(struct getuserinfo, 1);
698 info->gc = connections->data; 701 info->gc = connections->data;
699 imdialog = gtk_dialog_new_with_buttons(_("Gaim - New Message"), blist ? GTK_WINDOW(blist) : NULL, GTK_DIALOG_MODAL, 702 imdialog = gtk_dialog_new_with_buttons(_("Gaim - New Message"), blist ? GTK_WINDOW(blist) : NULL, GTK_DIALOG_MODAL,
700 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); 703 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
701 gtk_dialog_set_default_response (GTK_DIALOG(imdialog), GTK_RESPONSE_OK); 704 gtk_dialog_set_default_response (GTK_DIALOG(imdialog), GTK_RESPONSE_OK);
702 gtk_container_set_border_width (GTK_CONTAINER(imdialog), 6); 705 gtk_container_set_border_width (GTK_CONTAINER(imdialog), 6);
703 gtk_window_set_resizable(GTK_WINDOW(imdialog), FALSE); 706 gtk_window_set_resizable(GTK_WINDOW(imdialog), FALSE);
704 gtk_dialog_set_has_separator(GTK_DIALOG(imdialog), FALSE); 707 gtk_dialog_set_has_separator(GTK_DIALOG(imdialog), FALSE);
705 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(imdialog)->vbox), 12); 708 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(imdialog)->vbox), 12);
706 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), 6); 709 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), 6);
707 710 gtk_dialog_set_response_sensitive(GTK_DIALOG(imdialog), GTK_RESPONSE_OK, FALSE);
711
708 hbox = gtk_hbox_new(FALSE, 12); 712 hbox = gtk_hbox_new(FALSE, 12);
709 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), hbox); 713 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), hbox);
710 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); 714 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
711 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); 715 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
712 716
713 vbox = gtk_vbox_new(FALSE, 0); 717 vbox = gtk_vbox_new(FALSE, 0);
714 gtk_container_add(GTK_CONTAINER(hbox), vbox); 718 gtk_container_add(GTK_CONTAINER(hbox), vbox);
715 719
716 label = gtk_label_new(_("Please enter the screenname of the person you would like to IM.\n")); 720 label = gtk_label_new(_("Please enter the screenname of the person you would like to IM.\n"));
717 gtk_widget_set_size_request(GTK_WIDGET(label), 350, -1); 721 gtk_widget_set_size_request(GTK_WIDGET(label), 350, -1);
718 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); 722 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
719 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 723 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
720 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 724 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
721 725
722 hbox = gtk_hbox_new(FALSE, 6); 726 hbox = gtk_hbox_new(FALSE, 6);
723 gtk_container_add(GTK_CONTAINER(vbox), hbox); 727 gtk_container_add(GTK_CONTAINER(vbox), hbox);
724 728
725 table = gtk_table_new(2, 2, FALSE); 729 table = gtk_table_new(2, 2, FALSE);
726 gtk_table_set_row_spacings(GTK_TABLE(table), 6); 730 gtk_table_set_row_spacings(GTK_TABLE(table), 6);
727 gtk_table_set_col_spacings(GTK_TABLE(table), 6); 731 gtk_table_set_col_spacings(GTK_TABLE(table), 6);
728 gtk_container_set_border_width(GTK_CONTAINER(table), 12); 732 gtk_container_set_border_width(GTK_CONTAINER(table), 12);
729 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); 733 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
730 734
731 label = gtk_label_new(NULL); 735 label = gtk_label_new(NULL);
732 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname:")); 736 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname:"));
733 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 737 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
734 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); 738 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
735 739
736 info->entry = gtk_entry_new(); 740 info->entry = gtk_entry_new();
737 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); 741 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1);
738 gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE); 742 gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE);
739 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry)); 743 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry));
744 g_signal_connect(G_OBJECT(info->entry), "changed",
745 G_CALLBACK(im_dialog_set_ok_sensitive), NULL);
740 746
741 if (connections->next) { 747 if (connections->next) {
742 748
743 label = gtk_label_new(NULL); 749 label = gtk_label_new(NULL);
744 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); 750 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
745 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:")); 751 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
746 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 752 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
747 753
748 info->account = gtk_option_menu_new(); 754 info->account = gtk_option_menu_new();
749 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2); 755 gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2);
750 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account)); 756 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account));
751 757
752 menu = gtk_menu_new(); 758 menu = gtk_menu_new();
753 759
754 while (g) { 760 while (g) {
755 c = (struct gaim_connection *)g->data; 761 c = (struct gaim_connection *)g->data;
756 if (!c->prpl->send_im) { 762 if (!c->prpl->send_im) {
757 g = g->next; 763 g = g->next;
758 continue; 764 continue;
759 } 765 }
760 g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name); 766 g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name);
761 opt = gtk_menu_item_new_with_label(buf); 767 opt = gtk_menu_item_new_with_label(buf);
762 gtk_object_set_user_data(GTK_OBJECT(opt), info); 768 gtk_object_set_user_data(GTK_OBJECT(opt), info);
763 769
764 g_signal_connect(GTK_OBJECT(opt), "activate", 770 g_signal_connect(GTK_OBJECT(opt), "activate",
765 G_CALLBACK(show_info_select_account), c); 771 G_CALLBACK(show_info_select_account), c);
766 772
767 gtk_menu_append(GTK_MENU(menu), opt); 773 gtk_menu_append(GTK_MENU(menu), opt);
768 g = g->next; 774 g = g->next;
769 } 775 }
770 776
771 gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu); 777 gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu);
772 } 778 }
773 779
774 g_signal_connect(G_OBJECT(imdialog), "response", G_CALLBACK(do_im), info); 780 g_signal_connect(G_OBJECT(imdialog), "response", G_CALLBACK(do_im), info);
775 } 781 }
776 782
777 gtk_widget_show_all(imdialog); 783 gtk_widget_show_all(imdialog);
778 if (info) 784 if (info)
779 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); 785 gtk_widget_grab_focus(GTK_WIDGET(info->entry));
780 } 786 }
781 787