Mercurial > pidgin.yaz
comparison src/dialogs.c @ 7927:1441648fe974
[gaim-migrate @ 8598]
De-uglify the insert link and insert image buttons a bit. Closing the
insert image dialog via the window manager now makes the insert image
button un-depress itself.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 25 Dec 2003 09:23:27 +0000 |
parents | 2014b91db201 |
children | 451d2946423e |
comparison
equal
deleted
inserted
replaced
7926:68900f9cb540 | 7927:1441648fe974 |
---|---|
78 GtkWidget *ok; | 78 GtkWidget *ok; |
79 GtkWidget *cancel; | 79 GtkWidget *cancel; |
80 GtkWidget *window; | 80 GtkWidget *window; |
81 GtkWidget *url; | 81 GtkWidget *url; |
82 GtkWidget *text; | 82 GtkWidget *text; |
83 GtkWidget *toggle; | |
84 GtkWidget *entry; | 83 GtkWidget *entry; |
85 GaimConversation *c; | 84 GaimConversation *c; |
86 }; | 85 }; |
87 | 86 |
88 struct view_log { | 87 struct view_log { |
232 hbox = gtk_hbox_new(FALSE, 6); | 231 hbox = gtk_hbox_new(FALSE, 6); |
233 gtk_container_add(GTK_CONTAINER(vbox), hbox); | 232 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
234 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU); | 233 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU); |
235 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 234 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
236 labeltext = _("<b>Anonymous warnings are less severe.</b>"); | 235 labeltext = _("<b>Anonymous warnings are less severe.</b>"); |
237 /* labeltext = _("Anonymous warnings are less severe."); */ | |
238 label = gtk_label_new(NULL); | 236 label = gtk_label_new(NULL); |
239 gtk_label_set_markup(GTK_LABEL(label), labeltext); | 237 gtk_label_set_markup(GTK_LABEL(label), labeltext); |
240 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 238 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
241 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 239 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
242 | 240 |
676 gtk_widget_show_all(window); | 674 gtk_widget_show_all(window); |
677 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); | 675 gtk_widget_grab_focus(GTK_WIDGET(info->entry)); |
678 } | 676 } |
679 | 677 |
680 | 678 |
681 static void | |
682 free_dialog(GtkWidget *w, void *data) | |
683 { | |
684 g_free(data); | |
685 } | |
686 | |
687 /*------------------------------------------------------*/ | 679 /*------------------------------------------------------*/ |
688 /* Link Dialog */ | 680 /* Link Dialog */ |
689 /*------------------------------------------------------*/ | 681 /*------------------------------------------------------*/ |
690 | 682 |
691 void cancel_link(GtkWidget *widget, GaimConversation *c) | 683 void dialog_link_destroy(GaimConversation *c) |
692 { | 684 { |
693 GaimGtkConversation *gtkconv; | 685 GaimGtkConversation *gtkconv; |
694 GtkWidget *link_dialog; | |
695 | 686 |
696 gtkconv = GAIM_GTK_CONVERSATION(c); | 687 gtkconv = GAIM_GTK_CONVERSATION(c); |
697 | 688 |
698 if (gtkconv->toolbar.link) { | 689 gtk_widget_destroy(gtkconv->dialogs.link); |
699 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link), | |
700 FALSE); | |
701 } | |
702 | |
703 link_dialog = gtkconv->dialogs.link; | |
704 gtkconv->dialogs.link = NULL; | 690 gtkconv->dialogs.link = NULL; |
705 destroy_dialog(NULL, link_dialog); | 691 } |
706 } | 692 |
707 | 693 static void do_insert_link(GtkWidget *w, int resp, struct linkdlg *a) |
708 void do_insert_link(GtkWidget *w, int resp, struct linkdlg *b) | |
709 { | 694 { |
710 GaimGtkConversation *gtkconv; | 695 GaimGtkConversation *gtkconv; |
711 char *open_tag; | |
712 const char *urltext, *showtext; | 696 const char *urltext, *showtext; |
713 | 697 |
714 gtkconv = GAIM_GTK_CONVERSATION(b->c); | 698 gtkconv = GAIM_GTK_CONVERSATION(a->c); |
715 | 699 |
716 if (resp == GTK_RESPONSE_OK) { | 700 if (resp == GTK_RESPONSE_OK) { |
717 | 701 urltext = gtk_entry_get_text(GTK_ENTRY(a->url)); |
718 open_tag = g_malloc(2048); | 702 showtext = gtk_entry_get_text(GTK_ENTRY(a->text)); |
719 | |
720 urltext = gtk_entry_get_text(GTK_ENTRY(b->url)); | |
721 showtext = gtk_entry_get_text(GTK_ENTRY(b->text)); | |
722 | 703 |
723 if (!strlen(showtext)) | 704 if (!strlen(showtext)) |
724 showtext = urltext; | 705 showtext = urltext; |
725 | 706 |
726 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), urltext, showtext); | 707 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), urltext, showtext); |
727 | 708 gaim_gtk_advance_past(gtkconv, "<A HREF>", "</A>"); |
728 g_free(open_tag); | 709 } |
729 } | 710 |
730 | 711 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link), FALSE); |
731 if (gtkconv->toolbar.link) { | 712 } |
732 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link), | 713 |
733 FALSE); | 714 static void dialog_link_freedata(GtkWidget *w, gpointer user_data) |
734 } | 715 { |
735 | 716 struct linkdlg *a = user_data; |
736 gtkconv->dialogs.link = NULL; | 717 |
737 destroy_dialog(NULL, b->window); | 718 g_free(a); |
738 } | 719 } |
739 | 720 |
740 void show_insert_link(GtkWidget *linky, GaimConversation *c) | 721 void dialog_link_show(GaimConversation *c) |
741 { | 722 { |
742 GaimGtkConversation *gtkconv; | 723 GaimGtkConversation *gtkconv; |
743 GaimGtkWindow *gtkwin; | 724 GaimGtkWindow *gtkwin; |
744 GtkWidget *table; | 725 GtkWidget *table; |
745 GtkWidget *label; | 726 GtkWidget *label; |
746 GtkWidget *hbox; | 727 GtkWidget *hbox; |
747 GtkWidget *vbox; | 728 GtkWidget *vbox; |
729 struct linkdlg *a; | |
730 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); | |
748 | 731 |
749 gtkconv = GAIM_GTK_CONVERSATION(c); | 732 gtkconv = GAIM_GTK_CONVERSATION(c); |
750 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); | 733 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(c)); |
751 | 734 |
752 if (gtkconv->dialogs.link == NULL) { | 735 a = g_new0(struct linkdlg, 1); |
753 struct linkdlg *a = g_new0(struct linkdlg, 1); | 736 |
754 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); | 737 a->c = c; |
755 | 738 a->window = gtk_dialog_new_with_buttons(_("Insert Link"), |
756 a->c = c; | 739 GTK_WINDOW(gtkwin->window), 0, GTK_STOCK_CANCEL, |
757 a->window = gtk_dialog_new_with_buttons(_("Insert Link"), | 740 GTK_RESPONSE_CANCEL, _("_Insert"), GTK_RESPONSE_OK, NULL); |
758 GTK_WINDOW(gtkwin->window), 0, GTK_STOCK_CANCEL, | 741 gtk_dialog_set_default_response(GTK_DIALOG(a->window), GTK_RESPONSE_OK); |
759 GTK_RESPONSE_CANCEL, _("_Insert"), GTK_RESPONSE_OK, NULL); | 742 g_signal_connect(G_OBJECT(a->window), "response", |
760 gtk_dialog_set_default_response(GTK_DIALOG(a->window), GTK_RESPONSE_OK); | 743 G_CALLBACK(do_insert_link), a); |
761 g_signal_connect(G_OBJECT(a->window), "response", | 744 g_signal_connect(G_OBJECT(a->window), "destroy", |
762 G_CALLBACK(do_insert_link), a); | 745 G_CALLBACK(dialog_link_freedata), a); |
763 | 746 |
764 gtk_dialog_set_default_response(GTK_DIALOG(a->window), GTK_RESPONSE_OK); | 747 gtk_dialog_set_default_response(GTK_DIALOG(a->window), GTK_RESPONSE_OK); |
765 gtk_container_set_border_width(GTK_CONTAINER(a->window), 6); | 748 gtk_container_set_border_width(GTK_CONTAINER(a->window), 6); |
766 gtk_window_set_resizable(GTK_WINDOW(a->window), FALSE); | 749 gtk_window_set_resizable(GTK_WINDOW(a->window), FALSE); |
767 gtk_dialog_set_has_separator(GTK_DIALOG(a->window), FALSE); | 750 gtk_dialog_set_has_separator(GTK_DIALOG(a->window), FALSE); |
768 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(a->window)->vbox), 12); | 751 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(a->window)->vbox), 12); |
769 gtk_container_set_border_width( | 752 gtk_container_set_border_width( |
770 GTK_CONTAINER(GTK_DIALOG(a->window)->vbox), 6); | 753 GTK_CONTAINER(GTK_DIALOG(a->window)->vbox), 6); |
771 gtk_window_set_role(GTK_WINDOW(a->window), "insert_link"); | 754 gtk_window_set_role(GTK_WINDOW(a->window), "insert_link"); |
772 gtk_dialog_set_response_sensitive(GTK_DIALOG(a->window), GTK_RESPONSE_OK, FALSE); | 755 gtk_dialog_set_response_sensitive(GTK_DIALOG(a->window), GTK_RESPONSE_OK, FALSE); |
773 | 756 |
774 hbox = gtk_hbox_new(FALSE, 12); | 757 hbox = gtk_hbox_new(FALSE, 12); |
775 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(a->window)->vbox), hbox); | 758 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(a->window)->vbox), hbox); |
776 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 759 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
777 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | 760 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
778 | 761 |
779 vbox = gtk_vbox_new(FALSE, 0); | 762 vbox = gtk_vbox_new(FALSE, 0); |
780 gtk_container_add(GTK_CONTAINER(hbox), vbox); | 763 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
781 | 764 |
782 label = gtk_label_new(_("Please enter the URL and description of " | 765 label = gtk_label_new(_("Please enter the URL and description of " |
783 "the link that you want to insert. The " | 766 "the link that you want to insert. The " |
784 "description is optional.\n")); | 767 "description is optional.\n")); |
785 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 768 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
786 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | 769 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
787 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | 770 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
788 | 771 |
789 table = gtk_table_new(2, 2, FALSE); | 772 table = gtk_table_new(2, 2, FALSE); |
790 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | 773 gtk_table_set_row_spacings(GTK_TABLE(table), 6); |
791 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | 774 gtk_table_set_col_spacings(GTK_TABLE(table), 6); |
792 gtk_container_set_border_width(GTK_CONTAINER(table), 0); | 775 gtk_container_set_border_width(GTK_CONTAINER(table), 0); |
793 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | 776 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
794 | 777 |
795 label = gtk_label_new_with_mnemonic(_("_URL:")); | 778 label = gtk_label_new_with_mnemonic(_("_URL:")); |
796 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 779 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
797 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | 780 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); |
798 | 781 |
799 a->url = gtk_entry_new(); | 782 a->url = gtk_entry_new(); |
800 gtk_table_attach_defaults(GTK_TABLE(table), a->url, 1, 2, 0, 1); | 783 gtk_table_attach_defaults(GTK_TABLE(table), a->url, 1, 2, 0, 1); |
801 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(a->url)); | 784 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(a->url)); |
802 gtk_widget_grab_focus(a->url); | 785 gtk_widget_grab_focus(a->url); |
803 | 786 |
804 gtk_entry_set_activates_default (GTK_ENTRY(a->url), TRUE); | 787 gtk_entry_set_activates_default (GTK_ENTRY(a->url), TRUE); |
805 g_signal_connect(G_OBJECT(a->url), "changed", | 788 g_signal_connect(G_OBJECT(a->url), "changed", |
806 G_CALLBACK(gaim_gtk_set_sensitive_if_input), a->window); | 789 G_CALLBACK(gaim_gtk_set_sensitive_if_input), a->window); |
807 | 790 |
808 label = gtk_label_new_with_mnemonic(_("_Description:")); | 791 label = gtk_label_new_with_mnemonic(_("_Description:")); |
809 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 792 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
810 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | 793 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
811 | 794 |
812 a->text = gtk_entry_new(); | 795 a->text = gtk_entry_new(); |
813 gtk_table_attach_defaults(GTK_TABLE(table), a->text, 1, 2, 1, 2); | 796 gtk_table_attach_defaults(GTK_TABLE(table), a->text, 1, 2, 1, 2); |
814 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(a->text)); | 797 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(a->text)); |
815 gtk_entry_set_activates_default (GTK_ENTRY(a->text), TRUE); | 798 gtk_entry_set_activates_default (GTK_ENTRY(a->text), TRUE); |
816 | 799 |
817 g_signal_connect(G_OBJECT(a->window), "destroy", | 800 gtkconv->dialogs.link = a->window; |
818 G_CALLBACK(free_dialog), a); | |
819 dialogwindows = g_list_prepend(dialogwindows, a->window); | |
820 | |
821 a->toggle = linky; | |
822 gtkconv->dialogs.link = a->window; | |
823 } | |
824 | 801 |
825 gtk_widget_show_all(gtkconv->dialogs.link); | 802 gtk_widget_show_all(gtkconv->dialogs.link); |
826 gdk_window_raise(gtkconv->dialogs.link->window); | 803 gdk_window_raise(gtkconv->dialogs.link->window); |
827 } | 804 } |
828 | 805 |