Mercurial > pidgin.yaz
comparison src/dialogs.c @ 8317:6f549c1d0829
[gaim-migrate @ 9041]
Because I won't be able to work on this until late this week at the earliest,
here's GtkIMHtmlToolbar. It's a composite widget that attaches to an editable
gtkimhtml and controls all the formatting with ease. All one has to do to get
a formattable, editable, gtkimhtml now is to replace a gtktextview with a
gtkimhtml (you can even leave all the other calls that control it as gtkimhtml
descends from gtktextview) throw one of these toolbars in there and
gtk_imhtml_toolbar_attach it to the gtkimhtml. That's what I did in the New
Away Message dialog. This would also be nice in gtkrequest.c and gtkpounce.c.
Of course, this isn't done and there's a ton of hacky commented out old code in
there. Things like keyboard shortcut preferences don't currently work and
there's a lot of things I want to move around yet. However, if anyone feels
inspired to work on it before I get back to it feel free. Maybe you can IM me
beforehand or something.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 23 Feb 2004 21:18:27 +0000 |
parents | 462ead6fc1a0 |
children | a2c5537a814b |
comparison
equal
deleted
inserted
replaced
8316:cf84056fed27 | 8317:6f549c1d0829 |
---|---|
32 #include "util.h" | 32 #include "util.h" |
33 | 33 |
34 #include "gtkblist.h" | 34 #include "gtkblist.h" |
35 #include "gtkconv.h" | 35 #include "gtkconv.h" |
36 #include "gtkimhtml.h" | 36 #include "gtkimhtml.h" |
37 #include "gtkimhtmltoolbar.h" | |
37 #include "gtkprefs.h" | 38 #include "gtkprefs.h" |
38 #include "gtkutils.h" | 39 #include "gtkutils.h" |
39 #include "stock.h" | 40 #include "stock.h" |
40 | 41 |
41 #include "ui.h" | 42 #include "ui.h" |
55 GaimConnection *gc; | 56 GaimConnection *gc; |
56 }; | 57 }; |
57 | 58 |
58 struct create_away { | 59 struct create_away { |
59 GtkWidget *window; | 60 GtkWidget *window; |
61 GtkWidget *toolbar; | |
60 GtkWidget *entry; | 62 GtkWidget *entry; |
61 GtkWidget *text; | 63 GtkWidget *text; |
62 struct away_message *mess; | 64 struct away_message *mess; |
63 }; | 65 }; |
64 | 66 |
110 | 112 |
111 object_data = g_object_get_data(G_OBJECT(w), "dialog_type"); | 113 object_data = g_object_get_data(G_OBJECT(w), "dialog_type"); |
112 | 114 |
113 gtkconv = GAIM_GTK_CONVERSATION(c); | 115 gtkconv = GAIM_GTK_CONVERSATION(c); |
114 | 116 |
115 if (GTK_IS_COLOR_SELECTION_DIALOG(w)) { | 117 /*if (GTK_IS_COLOR_SELECTION_DIALOG(w)) { |
116 if (w == gtkconv->dialogs.fg_color) { | 118 if (w == gtkconv->dialogs.fg_color) { |
117 gtk_toggle_button_set_active( | 119 gtk_toggle_button_set_active( |
118 GTK_TOGGLE_BUTTON(gtkconv->toolbar.fgcolor), FALSE); | 120 GTK_TOGGLE_BUTTON(gtkconv->toolbar.fgcolor), FALSE); |
119 gtkconv->dialogs.fg_color = NULL; | 121 gtkconv->dialogs.fg_color = NULL; |
120 } else { | 122 } else { |
132 gtkconv->dialogs.smiley = NULL; | 134 gtkconv->dialogs.smiley = NULL; |
133 } else if (!g_ascii_strcasecmp(object_data, "log dialog")) { | 135 } else if (!g_ascii_strcasecmp(object_data, "log dialog")) { |
134 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->toolbar.log), | 136 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->toolbar.log), |
135 FALSE); | 137 FALSE); |
136 gtkconv->dialogs.log = NULL; | 138 gtkconv->dialogs.log = NULL; |
137 } | 139 }*/ |
138 | 140 |
139 dialogwindows = g_list_remove(dialogwindows, w); | 141 dialogwindows = g_list_remove(dialogwindows, w); |
140 gtk_widget_destroy(w); | 142 gtk_widget_destroy(w); |
141 | 143 |
142 return FALSE; | 144 return FALSE; |
572 /*------------------------------------------------------*/ | 574 /*------------------------------------------------------*/ |
573 | 575 |
574 GtkWidget *fgcseld = NULL; | 576 GtkWidget *fgcseld = NULL; |
575 GtkWidget *bgcseld = NULL; | 577 GtkWidget *bgcseld = NULL; |
576 | 578 |
577 void cancel_fgcolor(GtkWidget *widget, GaimConversation *c) | |
578 { | |
579 GaimGtkConversation *gtkconv; | |
580 | |
581 gtkconv = GAIM_GTK_CONVERSATION(c); | |
582 | |
583 if (gtkconv->toolbar.fgcolor && widget) { | |
584 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.fgcolor), | |
585 FALSE); | |
586 } | |
587 | |
588 dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.fg_color); | |
589 gtk_widget_destroy(gtkconv->dialogs.fg_color); | |
590 gtkconv->dialogs.fg_color = NULL; | |
591 } | |
592 | |
593 void cancel_bgcolor(GtkWidget *widget, GaimConversation *c) | |
594 { | |
595 GaimGtkConversation *gtkconv; | |
596 | |
597 gtkconv = GAIM_GTK_CONVERSATION(c); | |
598 | |
599 if (gtkconv->toolbar.bgcolor && widget) { | |
600 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.bgcolor), | |
601 FALSE); | |
602 } | |
603 | |
604 dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.bg_color); | |
605 gtk_widget_destroy(gtkconv->dialogs.bg_color); | |
606 gtkconv->dialogs.bg_color = NULL; | |
607 } | |
608 | |
609 void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
610 { | |
611 GdkColor text_color; | |
612 GaimConversation *c; | |
613 GaimGtkConversation *gtkconv; | |
614 char *open_tag; | |
615 | |
616 open_tag = g_malloc(30); | |
617 | |
618 gtk_color_selection_get_current_color(colorsel, &text_color); | |
619 | |
620 c = g_object_get_data(G_OBJECT(colorsel), "gaim_conversation"); | |
621 /* GTK_IS_EDITABLE(c->entry); huh? */ | |
622 | |
623 gtkconv = GAIM_GTK_CONVERSATION(c); | |
624 | |
625 gtkconv->fg_color = text_color; | |
626 g_snprintf(open_tag, 23, "#%02X%02X%02X", | |
627 text_color.red / 256, | |
628 text_color.green / 256, | |
629 text_color.blue / 256); | |
630 gtk_imhtml_toggle_forecolor(GTK_IMHTML(gtkconv->entry), open_tag); | |
631 | |
632 g_free(open_tag); | |
633 cancel_fgcolor(NULL, c); | |
634 } | |
635 | |
636 void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
637 { | |
638 GdkColor text_color; | |
639 GaimConversation *c; | |
640 GaimGtkConversation *gtkconv; | |
641 char *open_tag; | |
642 | |
643 open_tag = g_malloc(30); | |
644 | |
645 gtk_color_selection_get_current_color(colorsel, &text_color); | |
646 | |
647 c = g_object_get_data(G_OBJECT(colorsel), "gaim_conversation"); | |
648 /* GTK_IS_EDITABLE(c->entry); huh? */ | |
649 | |
650 gtkconv = GAIM_GTK_CONVERSATION(c); | |
651 | |
652 gtkconv->bg_color = text_color; | |
653 g_snprintf(open_tag, 25, "#%02X%02X%02X", | |
654 text_color.red / 256, | |
655 text_color.green / 256, | |
656 text_color.blue / 256); | |
657 gtk_imhtml_toggle_backcolor(GTK_IMHTML(gtkconv->entry), open_tag); | |
658 | |
659 g_free(open_tag); | |
660 cancel_bgcolor(NULL, c); | |
661 } | |
662 | |
663 void show_fgcolor_dialog(GaimConversation *c, GtkWidget *color) | 579 void show_fgcolor_dialog(GaimConversation *c, GtkWidget *color) |
664 { | 580 { |
665 GaimGtkConversation *gtkconv; | 581 GaimGtkConversation *gtkconv; |
666 GtkWidget *colorsel; | 582 GtkWidget *colorsel; |
667 GdkColor fgcolor; | 583 GdkColor fgcolor; |
669 gtkconv = GAIM_GTK_CONVERSATION(c); | 585 gtkconv = GAIM_GTK_CONVERSATION(c); |
670 | 586 |
671 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | 587 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
672 &fgcolor); | 588 &fgcolor); |
673 | 589 |
674 if (color == NULL) { /* we came from the prefs */ | 590 if (fgcseld) |
675 if (fgcseld) | 591 return; |
676 return; | 592 |
677 | 593 fgcseld = gtk_color_selection_dialog_new(_("Select Text Color")); |
678 fgcseld = gtk_color_selection_dialog_new(_("Select Text Color")); | 594 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION |
679 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION | |
680 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), &fgcolor); | 595 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), &fgcolor); |
681 g_signal_connect(G_OBJECT(fgcseld), "delete_event", | 596 g_signal_connect(G_OBJECT(fgcseld), "delete_event", |
682 G_CALLBACK(destroy_colorsel), (void *)1); | 597 G_CALLBACK(destroy_colorsel), (void *)1); |
683 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->cancel_button), | 598 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->cancel_button), |
684 "clicked", G_CALLBACK(destroy_colorsel), (void *)1); | 599 "clicked", G_CALLBACK(destroy_colorsel), (void *)1); |
685 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->ok_button), "clicked", | 600 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->ok_button), "clicked", |
686 G_CALLBACK(apply_color_dlg), (void *)1); | 601 G_CALLBACK(apply_color_dlg), (void *)1); |
687 gtk_widget_realize(fgcseld); | 602 gtk_widget_realize(fgcseld); |
688 gtk_widget_show(fgcseld); | 603 gtk_widget_show(fgcseld); |
689 gdk_window_raise(fgcseld->window); | 604 gdk_window_raise(fgcseld->window); |
690 return; | 605 return; |
691 } | |
692 | |
693 if (!gtkconv->dialogs.fg_color) { | |
694 | |
695 gtkconv->dialogs.fg_color = gtk_color_selection_dialog_new(_("Select Text Color")); | |
696 colorsel = GTK_COLOR_SELECTION_DIALOG(gtkconv->dialogs.fg_color)->colorsel; | |
697 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor); | |
698 g_object_set_data(G_OBJECT(colorsel), "gaim_conversation", c); | |
699 | |
700 g_signal_connect(G_OBJECT(gtkconv->dialogs.fg_color), "delete_event", | |
701 G_CALLBACK(delete_event_dialog), c); | |
702 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(gtkconv->dialogs.fg_color)->ok_button), | |
703 "clicked", G_CALLBACK(do_fgcolor), colorsel); | |
704 g_signal_connect(G_OBJECT | |
705 (GTK_COLOR_SELECTION_DIALOG(gtkconv->dialogs.fg_color)->cancel_button), | |
706 "clicked", G_CALLBACK(cancel_fgcolor), c); | |
707 | |
708 gtk_widget_realize(gtkconv->dialogs.fg_color); | |
709 } | |
710 | |
711 gtk_widget_show(gtkconv->dialogs.fg_color); | |
712 gdk_window_raise(gtkconv->dialogs.fg_color->window); | |
713 } | 606 } |
714 | 607 |
715 void show_bgcolor_dialog(GaimConversation *c, GtkWidget *color) | 608 void show_bgcolor_dialog(GaimConversation *c, GtkWidget *color) |
716 { | 609 { |
717 GaimGtkConversation *gtkconv; | 610 GaimGtkConversation *gtkconv; |
721 gtkconv = GAIM_GTK_CONVERSATION(c); | 614 gtkconv = GAIM_GTK_CONVERSATION(c); |
722 | 615 |
723 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | 616 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
724 &bgcolor); | 617 &bgcolor); |
725 | 618 |
726 if (color == NULL) { /* we came from the prefs */ | 619 if (bgcseld) |
727 if (bgcseld) | 620 return; |
728 return; | 621 |
729 | 622 bgcseld = gtk_color_selection_dialog_new(_("Select Background Color")); |
730 bgcseld = gtk_color_selection_dialog_new(_("Select Background Color")); | 623 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION |
731 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION | |
732 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), &bgcolor); | 624 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), &bgcolor); |
733 g_signal_connect(G_OBJECT(bgcseld), "delete_event", | 625 g_signal_connect(G_OBJECT(bgcseld), "delete_event", |
734 G_CALLBACK(destroy_colorsel), NULL); | 626 G_CALLBACK(destroy_colorsel), NULL); |
735 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->cancel_button), | 627 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->cancel_button), |
736 "clicked", G_CALLBACK(destroy_colorsel), NULL); | 628 "clicked", G_CALLBACK(destroy_colorsel), NULL); |
737 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->ok_button), "clicked", | 629 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->ok_button), "clicked", |
738 G_CALLBACK(apply_color_dlg), (void *)2); | 630 G_CALLBACK(apply_color_dlg), (void *)2); |
739 gtk_widget_realize(bgcseld); | 631 gtk_widget_realize(bgcseld); |
740 gtk_widget_show(bgcseld); | 632 gtk_widget_show(bgcseld); |
741 gdk_window_raise(bgcseld->window); | 633 gdk_window_raise(bgcseld->window); |
742 return; | 634 return; |
743 } | 635 } |
744 | 636 |
745 if (!gtkconv->dialogs.bg_color) { | 637 |
746 | 638 /*------------------------ ----------------------------------------------*/ |
747 gtkconv->dialogs.bg_color = gtk_color_selection_dialog_new(_("Select Background Color")); | |
748 colorsel = GTK_COLOR_SELECTION_DIALOG(gtkconv->dialogs.bg_color)->colorsel; | |
749 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor); | |
750 g_object_set_data(G_OBJECT(colorsel), "gaim_conversation", c); | |
751 | |
752 g_signal_connect(G_OBJECT(gtkconv->dialogs.bg_color), "delete_event", | |
753 G_CALLBACK(delete_event_dialog), c); | |
754 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(gtkconv->dialogs.bg_color)->ok_button), | |
755 "clicked", G_CALLBACK(do_bgcolor), colorsel); | |
756 g_signal_connect(G_OBJECT | |
757 (GTK_COLOR_SELECTION_DIALOG(gtkconv->dialogs.bg_color)->cancel_button), | |
758 "clicked", G_CALLBACK(cancel_bgcolor), c); | |
759 | |
760 gtk_widget_realize(gtkconv->dialogs.bg_color); | |
761 } | |
762 | |
763 gtk_widget_show(gtkconv->dialogs.bg_color); | |
764 gdk_window_raise(gtkconv->dialogs.bg_color->window); | |
765 } | |
766 | |
767 /*------------------------------------------------------------------------*/ | |
768 /* Font Selection Dialog */ | 639 /* Font Selection Dialog */ |
769 /*------------------------------------------------------------------------*/ | 640 /*------------------------------------------------------------------------*/ |
770 | 641 |
771 void cancel_font(GtkWidget *widget, GaimConversation *c) | |
772 { | |
773 GaimGtkConversation *gtkconv; | |
774 | |
775 gtkconv = GAIM_GTK_CONVERSATION(c); | |
776 | |
777 if (gtkconv->toolbar.font && widget) { | |
778 gtk_toggle_button_set_active( | |
779 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font), FALSE); | |
780 } | |
781 | |
782 if (gtkconv->dialogs.font) { | |
783 dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.font); | |
784 gtk_widget_destroy(gtkconv->dialogs.font); | |
785 gtkconv->dialogs.font = NULL; | |
786 } | |
787 } | |
788 | |
789 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) | |
790 { | |
791 /* this could be expanded to include font size, weight, etc. | |
792 but for now only works with font face */ | |
793 char *fontname; | |
794 char *space; | |
795 GaimConversation *c = g_object_get_data(G_OBJECT(fontsel), | |
796 "gaim_conversation"); | |
797 | |
798 if(!c) | |
799 return; | |
800 | |
801 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); | |
802 | |
803 space = strrchr(fontname, ' '); | |
804 if(space && isdigit(*(space+1))) | |
805 *space = '\0'; | |
806 | |
807 gaim_gtk_set_font_face(GAIM_GTK_CONVERSATION(c), fontname); | |
808 | |
809 g_free(fontname); | |
810 | |
811 cancel_font(NULL, c); | |
812 } | |
813 | 642 |
814 void destroy_fontsel(GtkWidget *w, gpointer d) | 643 void destroy_fontsel(GtkWidget *w, gpointer d) |
815 { | 644 { |
816 gtk_widget_destroy(fontseld); | 645 gtk_widget_destroy(fontseld); |
817 fontseld = NULL; | 646 fontseld = NULL; |
823 char fonttif[128]; | 652 char fonttif[128]; |
824 const char *fontface; | 653 const char *fontface; |
825 | 654 |
826 gtkconv = GAIM_GTK_CONVERSATION(c); | 655 gtkconv = GAIM_GTK_CONVERSATION(c); |
827 | 656 |
828 if (!font) { /* we came from the prefs dialog */ | 657 |
829 if (fontseld) | 658 if (fontseld) |
830 return; | |
831 | |
832 fontseld = gtk_font_selection_dialog_new(_("Select Font")); | |
833 | |
834 fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face"); | |
835 | |
836 if (fontface != NULL && *fontface != '\0') { | |
837 g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontface); | |
838 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), | |
839 fonttif); | |
840 } else { | |
841 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), | |
842 DEFAULT_FONT_FACE " 12"); | |
843 } | |
844 | |
845 g_signal_connect(G_OBJECT(fontseld), "delete_event", | |
846 G_CALLBACK(destroy_fontsel), NULL); | |
847 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), | |
848 "clicked", G_CALLBACK(destroy_fontsel), NULL); | |
849 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", | |
850 G_CALLBACK(apply_font_dlg), fontseld); | |
851 gtk_widget_realize(fontseld); | |
852 gtk_widget_show(fontseld); | |
853 gdk_window_raise(fontseld->window); | |
854 return; | 659 return; |
660 | |
661 fontseld = gtk_font_selection_dialog_new(_("Select Font")); | |
662 | |
663 fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face"); | |
664 | |
665 if (fontface != NULL && *fontface != '\0') { | |
666 g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontface); | |
667 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), | |
668 fonttif); | |
669 } else { | |
670 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), | |
671 DEFAULT_FONT_FACE " 12"); | |
855 } | 672 } |
856 | 673 |
857 if (!gtkconv->dialogs.font) { | 674 g_signal_connect(G_OBJECT(fontseld), "delete_event", |
858 gtkconv->dialogs.font = gtk_font_selection_dialog_new(_("Select Font")); | 675 G_CALLBACK(destroy_fontsel), NULL); |
859 | 676 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), |
860 g_object_set_data(G_OBJECT(gtkconv->dialogs.font), "gaim_conversation", c); | 677 "clicked", G_CALLBACK(destroy_fontsel), NULL); |
861 | 678 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", |
862 if (gtkconv->fontface[0]) { | 679 G_CALLBACK(apply_font_dlg), fontseld); |
863 g_snprintf(fonttif, sizeof(fonttif), "%s 12", gtkconv->fontface); | 680 gtk_widget_realize(fontseld); |
864 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font), | 681 gtk_widget_show(fontseld); |
865 fonttif); | 682 gdk_window_raise(fontseld->window); |
866 } else { | 683 return; |
867 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font), | 684 |
868 DEFAULT_FONT_FACE); | |
869 } | |
870 | |
871 g_signal_connect(G_OBJECT(gtkconv->dialogs.font), "delete_event", | |
872 G_CALLBACK(delete_event_dialog), c); | |
873 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font)->ok_button), | |
874 "clicked", G_CALLBACK(apply_font), gtkconv->dialogs.font); | |
875 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font)->cancel_button), | |
876 "clicked", G_CALLBACK(cancel_font), c); | |
877 | |
878 gtk_widget_realize(gtkconv->dialogs.font); | |
879 | |
880 } | |
881 | |
882 gtk_widget_show(gtkconv->dialogs.font); | |
883 gdk_window_raise(gtkconv->dialogs.font->window); | |
884 } | 685 } |
885 | 686 |
886 /*------------------------------------------------------------------------*/ | 687 /*------------------------------------------------------------------------*/ |
887 /* The dialog for new away messages */ | 688 /* The dialog for new away messages */ |
888 /*------------------------------------------------------------------------*/ | 689 /*------------------------------------------------------------------------*/ |
897 else { | 698 else { |
898 am = ca->mess; | 699 am = ca->mess; |
899 } | 700 } |
900 | 701 |
901 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | 702 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); |
902 away_message = gtk_text_view_get_text(GTK_TEXT_VIEW(ca->text), FALSE); | 703 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); |
903 | 704 |
904 g_snprintf(am->message, sizeof(am->message), "%s", away_message); | 705 g_snprintf(am->message, sizeof(am->message), "%s", away_message); |
905 g_free(away_message); | 706 g_free(away_message); |
906 | 707 |
907 if (!ca->mess) | 708 if (!ca->mess) |
924 _("Please give the message a title, or choose " | 725 _("Please give the message a title, or choose " |
925 "\"Use\" to use without saving.")); | 726 "\"Use\" to use without saving.")); |
926 return 0; | 727 return 0; |
927 } | 728 } |
928 | 729 |
929 msg = gtk_text_view_get_text(GTK_TEXT_VIEW(ca->text), FALSE); | 730 msg = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); |
930 | 731 |
931 if (!msg && (type <= 1)) { | 732 if (!msg && (type <= 1)) { |
932 /* We shouldn't allow a blank message */ | 733 /* We shouldn't allow a blank message */ |
933 gaim_notify_error(NULL, NULL, | 734 gaim_notify_error(NULL, NULL, |
934 _("You cannot create an empty away message"), NULL); | 735 _("You cannot create an empty away message"), NULL); |
957 | 758 |
958 if (!check_away_mess(ca, 0)) | 759 if (!check_away_mess(ca, 0)) |
959 return; | 760 return; |
960 | 761 |
961 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | 762 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); |
962 away_message = gtk_text_view_get_text(GTK_TEXT_VIEW(ca->text), FALSE); | 763 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); |
963 | 764 |
964 g_snprintf(am.message, sizeof(am.message), "%s", away_message); | 765 g_snprintf(am.message, sizeof(am.message), "%s", away_message); |
965 g_free(away_message); | 766 g_free(away_message); |
966 | 767 |
967 do_away_message(NULL, &am); | 768 do_away_message(NULL, &am); |
1020 ca->entry = gtk_entry_new(); | 821 ca->entry = gtk_entry_new(); |
1021 gtk_box_pack_start(GTK_BOX(hbox), ca->entry, TRUE, TRUE, 0); | 822 gtk_box_pack_start(GTK_BOX(hbox), ca->entry, TRUE, TRUE, 0); |
1022 gaim_set_accessible_label (ca->entry, label); | 823 gaim_set_accessible_label (ca->entry, label); |
1023 gtk_widget_grab_focus(ca->entry); | 824 gtk_widget_grab_focus(ca->entry); |
1024 | 825 |
826 /* Toolbar */ | |
827 ca->toolbar = gtk_imhtmltoolbar_new(); | |
828 gtk_box_pack_start(GTK_BOX(vbox), ca->toolbar, FALSE, FALSE, 0); | |
829 | |
1025 /* Away message text */ | 830 /* Away message text */ |
1026 sw = gtk_scrolled_window_new(NULL, NULL); | 831 sw = gtk_scrolled_window_new(NULL, NULL); |
1027 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | 832 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
1028 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 833 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
1029 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | 834 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
1030 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | 835 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
1031 | 836 |
1032 ca->text = gtk_text_view_new(); | 837 ca->text = gtk_imhtml_new(NULL, NULL); |
838 gtk_imhtml_set_editable(ca->text, TRUE); | |
1033 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(ca->text), GTK_WRAP_WORD_CHAR); | 839 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(ca->text), GTK_WRAP_WORD_CHAR); |
1034 | 840 |
1035 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | 841 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
1036 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(ca->text)); | 842 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(ca->text)); |
843 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(ca->toolbar), ca->text); | |
1037 | 844 |
1038 gtk_container_add(GTK_CONTAINER(sw), ca->text); | 845 gtk_container_add(GTK_CONTAINER(sw), ca->text); |
1039 | 846 |
1040 if (dummy) { | 847 if (dummy) { |
1041 struct away_message *amt; | 848 struct away_message *amt; |
1050 if (! gtk_tree_selection_get_selected (sel, (GtkTreeModel**)&ls, &iter)) | 857 if (! gtk_tree_selection_get_selected (sel, (GtkTreeModel**)&ls, &iter)) |
1051 return; | 858 return; |
1052 gtk_tree_model_get_value (GTK_TREE_MODEL(ls), &iter, 1, &val); | 859 gtk_tree_model_get_value (GTK_TREE_MODEL(ls), &iter, 1, &val); |
1053 amt = g_value_get_pointer (&val); | 860 amt = g_value_get_pointer (&val); |
1054 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name); | 861 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name); |
1055 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ca->text)); | 862 gtk_imhtml_append_text_with_images(GTK_IMHTML(ca->text), amt->message, 0, NULL); |
1056 gtk_text_buffer_get_iter_at_offset(buffer, &start, pos); | |
1057 gtk_text_buffer_insert(buffer, &start, amt->message, strlen(amt->message)); | |
1058 | |
1059 ca->mess = amt; | 863 ca->mess = amt; |
1060 } | 864 } |
1061 | 865 |
1062 hbox = gtk_hbox_new(FALSE, 5); | 866 hbox = gtk_hbox_new(FALSE, 5); |
1063 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 867 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1077 button = gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); | 881 button = gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); |
1078 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(destroy_dialog), ca->window); | 882 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(destroy_dialog), ca->window); |
1079 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 883 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1080 | 884 |
1081 gtk_widget_show_all(ca->window); | 885 gtk_widget_show_all(ca->window); |
1082 } | |
1083 | |
1084 /* smiley dialog */ | |
1085 | |
1086 void close_smiley_dialog(GtkWidget *widget, GaimConversation *c) | |
1087 { | |
1088 GaimGtkConversation *gtkconv; | |
1089 | |
1090 gtkconv = GAIM_GTK_CONVERSATION(c); | |
1091 | |
1092 if (gtkconv->toolbar.smiley) { | |
1093 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.smiley), | |
1094 FALSE); | |
1095 } | |
1096 if(gtkconv->dialogs.smiley) { | |
1097 dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.smiley); | |
1098 gtk_widget_destroy(gtkconv->dialogs.smiley); | |
1099 gtkconv->dialogs.smiley = NULL; | |
1100 } | |
1101 } | |
1102 | |
1103 void insert_smiley_text(GtkWidget *widget, GaimConversation *c) | |
1104 { | |
1105 GaimGtkConversation *gtkconv; | |
1106 char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | |
1107 GaimPlugin *proto = gaim_find_prpl(gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | |
1108 | |
1109 gtkconv = GAIM_GTK_CONVERSATION(c); | |
1110 | |
1111 gtk_imhtml_insert_smiley(GTK_IMHTML(gtkconv->entry), proto->info->name, smiley_text); | |
1112 | |
1113 close_smiley_dialog(NULL, c); | |
1114 } | |
1115 | |
1116 static void add_smiley(GaimConversation *c, GtkWidget *table, int row, int col, char *filename, char *face) | |
1117 { | |
1118 GtkWidget *image; | |
1119 GtkWidget *button; | |
1120 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(c); | |
1121 | |
1122 image = gtk_image_new_from_file(filename); | |
1123 button = gtk_button_new(); | |
1124 gtk_container_add(GTK_CONTAINER(button), image); | |
1125 g_object_set_data(G_OBJECT(button), "smiley_text", face); | |
1126 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), c); | |
1127 | |
1128 gtk_tooltips_set_tip(gtkconv->tooltips, button, face, NULL); | |
1129 | |
1130 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1); | |
1131 | |
1132 /* these look really weird with borders */ | |
1133 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
1134 | |
1135 gtk_widget_show(button); | |
1136 } | |
1137 | |
1138 static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) { | |
1139 while(list) { | |
1140 GtkIMHtmlSmiley *cur = list->data; | |
1141 if(!strcmp(cur->file, smiley->file)) | |
1142 return FALSE; | |
1143 list = list->next; | |
1144 } | |
1145 return TRUE; | |
1146 } | |
1147 | |
1148 void show_smiley_dialog(GaimConversation *c, GtkWidget *widget) | |
1149 { | |
1150 GaimGtkConversation *gtkconv; | |
1151 GtkWidget *dialog; | |
1152 GtkWidget *smiley_table = NULL; | |
1153 GSList *smileys, *unique_smileys = NULL; | |
1154 int width; | |
1155 int row = 0, col = 0; | |
1156 | |
1157 gtkconv = GAIM_GTK_CONVERSATION(c); | |
1158 | |
1159 if (gtkconv->dialogs.smiley) | |
1160 return; | |
1161 | |
1162 if(c->account) | |
1163 smileys = get_proto_smileys( | |
1164 gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | |
1165 else | |
1166 smileys = get_proto_smileys(GAIM_PROTO_DEFAULT); | |
1167 | |
1168 while(smileys) { | |
1169 GtkIMHtmlSmiley *smiley = smileys->data; | |
1170 if(!smiley->hidden) { | |
1171 if(smiley_is_unique(unique_smileys, smiley)) | |
1172 unique_smileys = g_slist_append(unique_smileys, smiley); | |
1173 } | |
1174 smileys = smileys->next; | |
1175 } | |
1176 | |
1177 | |
1178 width = floor(sqrt(g_slist_length(unique_smileys))); | |
1179 | |
1180 GAIM_DIALOG(dialog); | |
1181 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
1182 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); | |
1183 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); | |
1184 | |
1185 smiley_table = gtk_table_new(width, width, TRUE); | |
1186 | |
1187 /* pack buttons */ | |
1188 | |
1189 while(unique_smileys) { | |
1190 GtkIMHtmlSmiley *smiley = unique_smileys->data; | |
1191 if(!smiley->hidden) { | |
1192 add_smiley(c, smiley_table, row, col, smiley->file, smiley->smile); | |
1193 if(++col >= width) { | |
1194 col = 0; | |
1195 row++; | |
1196 } | |
1197 } | |
1198 unique_smileys = unique_smileys->next; | |
1199 } | |
1200 | |
1201 gtk_container_add(GTK_CONTAINER(dialog), smiley_table); | |
1202 | |
1203 gtk_widget_show(smiley_table); | |
1204 | |
1205 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); | |
1206 | |
1207 /* connect signals */ | |
1208 g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog"); | |
1209 g_signal_connect(G_OBJECT(dialog), "delete_event", | |
1210 G_CALLBACK(delete_event_dialog), c); | |
1211 | |
1212 /* show everything */ | |
1213 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!")); | |
1214 gtk_widget_show_all(dialog); | |
1215 | |
1216 gtkconv->dialogs.smiley = dialog; | |
1217 | |
1218 return; | |
1219 } | 886 } |
1220 | 887 |
1221 static void | 888 static void |
1222 alias_chat_cb(GaimChat *chat, const char *new_alias) | 889 alias_chat_cb(GaimChat *chat, const char *new_alias) |
1223 { | 890 { |