annotate src/gtkimhtmltoolbar.c @ 9169:3df7197abfe2

[gaim-migrate @ 9954] Parallel compiles of the perl plugin should work better (Stu Tomlinson). committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 03 Jun 2004 01:25:22 +0000
parents 812e7aa7eafa
children 2fa81d44ee6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * GtkIMHtmlToolbar
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * source distribution.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
23 #include "gtkinternal.h"
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "gtkimhtmltoolbar.h"
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "gtkutils.h"
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
27
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
28 #include "imgstore.h"
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "notify.h"
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "request.h"
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "stock.h"
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "ui.h"
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
33 #include "util.h"
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 static GtkVBoxClass *parent_class = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
39 GObject *object;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
40
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 g_return_if_fail(toolbar);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
42
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
43 /* block the format_function_toggle handler */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
44 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml)));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
45 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
46 NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml));
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
48 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
49 NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
50 g_object_unref(object);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
51
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
58 GObject *object;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
59
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 g_return_if_fail(toolbar);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
61
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
62 /* block the format_function_toggle handler */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
63 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml)));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
64 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
65 NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml));
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
67 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
68 NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
69 g_object_unref(object);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
70
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
77 GObject *object;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
78
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 g_return_if_fail(toolbar);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
80
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
81 /* block the format_function_toggle handler */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
82 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml)));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
83 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
84 NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml));
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
86 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
87 NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
88 g_object_unref(object);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
89
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 g_return_if_fail(toolbar);
8380
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8359
diff changeset
97 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size)))
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8359
diff changeset
98 gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 do_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 g_return_if_fail(toolbar);
8380
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8359
diff changeset
107 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->larger_size)))
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8359
diff changeset
108 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
113 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
114 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
115 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->font), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
119 if (toolbar->font_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
120 {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 gtk_widget_destroy(toolbar->font_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 toolbar->font_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
126 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
127 cancel_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
128 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
129 destroy_toolbar_font(widget, NULL, toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
130 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
131
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 static void apply_font(GtkWidget *widget, GtkFontSelection *fontsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 /* this could be expanded to include font size, weight, etc.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 but for now only works with font face */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 char *fontname;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 char *space;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 space = strrchr(fontname, ' ');
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 if(space && isdigit(*(space+1)))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 *space = '\0';
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 g_free(fontname);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
150 cancel_toolbar_font(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
156 const char *fontname;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
157
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 g_return_if_fail(toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
159
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
160 fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
161
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 if (!toolbar->font_dialog) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 g_object_set_data(G_OBJECT(toolbar->font_dialog), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
166
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
167 if(fontname) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
168 char fonttif[128];
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
169 g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontname);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
170 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
171 fonttif);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
172 } else {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
173 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
174 DEFAULT_FONT_FACE);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
175 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
176
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
178 G_CALLBACK(destroy_toolbar_font), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
179 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->ok_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
180 G_CALLBACK(apply_font), toolbar->font_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
181 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->cancel_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
182 G_CALLBACK(cancel_toolbar_font), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
183
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 gtk_window_present(GTK_WINDOW(toolbar->font_dialog));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 } else {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
186 cancel_toolbar_font(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
191 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
192 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
193 GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
194 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
195 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->fgcolor), FALSE);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
196
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
197 if (toolbar->fgcolor_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
198 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
199 gtk_widget_destroy(toolbar->fgcolor_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
200 toolbar->fgcolor_dialog = NULL;
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
201 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
202 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
203
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
204 static void cancel_toolbar_fgcolor(GtkWidget *widget,
8321
eb269b81fff8 [gaim-migrate @ 9045]
Christian Hammond <chipx86@chipx86.com>
parents: 8320
diff changeset
205 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
207 destroy_toolbar_fgcolor(widget, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 static void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 GdkColor text_color;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 char *open_tag;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 open_tag = g_malloc(30);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 gtk_color_selection_get_current_color(colorsel, &text_color);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 g_snprintf(open_tag, 23, "#%02X%02X%02X",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 text_color.red / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 text_color.green / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 text_color.blue / 256);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 g_free(open_tag);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
225 cancel_toolbar_fgcolor(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 toggle_fg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 GtkWidget *colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
233 GdkColor fgcolor;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
234 const char *color = gtk_imhtml_get_current_forecolor(GTK_IMHTML(toolbar->imhtml));
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
235
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 if (!toolbar->fgcolor_dialog) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
237
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
240 if (color) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
241 gdk_color_parse(color, &fgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
242 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
243 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
244
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
246
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
248 G_CALLBACK(destroy_toolbar_fgcolor), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
249 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->ok_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
250 G_CALLBACK(do_fgcolor), colorsel);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
251 g_signal_connect(G_OBJECT (GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->cancel_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
252 G_CALLBACK(cancel_toolbar_fgcolor), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
253
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
255 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 } else if (toolbar->fgcolor_dialog != NULL) {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
257 cancel_toolbar_fgcolor(color, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 } else {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
264 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
265 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
266 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->bgcolor), FALSE);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
269
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
270 if (toolbar->bgcolor_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
271 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
272 gtk_widget_destroy(toolbar->bgcolor_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
273 toolbar->bgcolor_dialog = NULL;
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
274 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
275 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
276
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
277 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
278 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
279 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
280 destroy_toolbar_bgcolor(widget, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 GdkColor text_color;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 char *open_tag;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 open_tag = g_malloc(30);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 gtk_color_selection_get_current_color(colorsel, &text_color);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 g_snprintf(open_tag, 23, "#%02X%02X%02X",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 text_color.red / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 text_color.green / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 text_color.blue / 256);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 g_free(open_tag);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
298 cancel_toolbar_bgcolor(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 GtkWidget *colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
306 GdkColor bgcolor;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
307 const char *color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(toolbar->imhtml));
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
308
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 if (!toolbar->bgcolor_dialog) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
310
8359
05c174138e94 [gaim-migrate @ 9083]
Mark Doliner <mark@kingant.net>
parents: 8325
diff changeset
311 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color"));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
313 if (color) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
314 gdk_color_parse(color, &bgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
315 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
316 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
317
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
319
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
321 G_CALLBACK(destroy_toolbar_bgcolor), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
322 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->ok_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
323 G_CALLBACK(do_bgcolor), colorsel);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
324 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->cancel_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
325 G_CALLBACK(cancel_toolbar_bgcolor), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
326
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
328 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 } else if (toolbar->bgcolor_dialog != NULL) {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
330 cancel_toolbar_bgcolor(color, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 } else {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 cancel_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
340 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
341
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 close_link_dialog(GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 if (toolbar->link_dialog != NULL)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 const char *url, *description;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 url = gaim_request_fields_get_string(fields, "url");
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
361 if (GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC)
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
362 description = gaim_request_fields_get_string(fields, "description");
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
363 else
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
364 description = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 if (description == NULL)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 description = url;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
369 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
370 gtk_text_buffer_get_insert(GTK_IMHTML(toolbar->imhtml)->text_buffer),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
371 url, description);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
372
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 GaimRequestFields *fields;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 GaimRequestFieldGroup *group;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 GaimRequestField *field;
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
385 char *msg;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
386
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 fields = gaim_request_fields_new();
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
388
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 group = gaim_request_field_group_new(NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 gaim_request_fields_add_group(fields, group);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
391
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 gaim_request_field_set_required(field, TRUE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 gaim_request_field_group_add_field(group, field);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
395
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
396 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) {
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
397 field = gaim_request_field_string_new("description", _("_Description"),
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
398 NULL, FALSE);
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
399 gaim_request_field_group_add_field(group, field);
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
400 msg = g_strdup(_("Please enter the URL and description of the "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
401 "link that you want to insert. The description "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
402 "is optional."));
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
403 } else {
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
404 msg = g_strdup(_("Please enter the URL of the "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
405 "link that you want to insert."));
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
406 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
407
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 toolbar->link_dialog =
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 gaim_request_fields(toolbar, _("Insert Link"),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 NULL,
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
411 msg,
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 fields,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 _("_Insert"), G_CALLBACK(do_insert_link_cb),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 _("Cancel"), G_CALLBACK(cancel_link_cb),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 toolbar);
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
416 g_free(msg);
8322
ffb601c6b833 [gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents: 8321
diff changeset
417 } else {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 close_link_dialog(toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 do_insert_image_cb(GtkWidget *widget, int resp, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 char *name, *filename;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 char *buf, *filedata;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 size_t size;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 GError *error = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 int id;
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
432 GtkTextIter iter;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
433 GtkTextMark *ins;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 if (resp != GTK_RESPONSE_OK) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 //set_toggle(toolbar->image, FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget)));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 if (!name) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(widget))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 g_free(name);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 if (!g_file_get_contents(name, &filedata, &size, &error)) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 gaim_notify_error(NULL, NULL, error->message, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 g_error_free(error);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 g_free(name);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 filename = name;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 while (strchr(filename, '/'))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 filename = strchr(filename, '/') + 1;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 id = gaim_imgstore_add(filedata, size, filename);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 g_free(filedata);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 if (!id) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 buf = g_strdup_printf(_("Failed to store image: %s\n"), name);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 gaim_notify_error(NULL, NULL, buf, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 g_free(buf);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 g_free(name);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
482 ins = gtk_text_buffer_get_insert(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)));
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
483 gtk_text_buffer_get_iter_at_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)),
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
484 &iter, ins);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
485 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(toolbar->imhtml), id, &iter);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
486 gaim_imgstore_unref(id);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
487
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 g_free(name);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 char buf[BUF_LONG];
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 GtkWidget *window;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 window = gtk_file_selection_new(_("Insert Image"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir());
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 "response", G_CALLBACK(do_insert_image_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 gtk_widget_show(window);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 toolbar->image_dialog = window;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 } else {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 gtk_widget_destroy(toolbar->image_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 toolbar->image_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
517 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
518 close_smiley_dialog(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
519 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
522
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
523 if (toolbar->smiley_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
524 {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 gtk_widget_destroy(toolbar->smiley_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 toolbar->smiley_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
531 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
532 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 {
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
534 char *smiley_text, *escaped_smiley;
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
535
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
536 smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text");
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
537 escaped_smiley = gaim_escape_html(smiley_text);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8447
diff changeset
539 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml),
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8447
diff changeset
540 GTK_IMHTML(toolbar->imhtml)->protocol_name,
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
541 escaped_smiley);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
543 g_free(escaped_smiley);
8320
5c6c8d48946f [gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents: 8319
diff changeset
544 close_smiley_dialog(NULL, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 static void add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 GtkWidget *image;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 GtkWidget *button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 image = gtk_image_new_from_file(filename);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 button = gtk_button_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 gtk_container_add(GTK_CONTAINER(button), image);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 g_object_set_data(G_OBJECT(button), "smiley_text", face);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 /* these look really weird with borders */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 gtk_widget_show(button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 while(list) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 GtkIMHtmlSmiley *cur = list->data;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 if(!strcmp(cur->file, smiley->file))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 return FALSE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 list = list->next;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
585
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 GtkWidget *dialog;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 GtkWidget *smiley_table = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 GSList *smileys, *unique_smileys = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 int width;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 int row = 0, col = 0;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
591
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 if (toolbar->smiley_dialog) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
596
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
597 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
598 smileys = get_proto_smileys(toolbar->sml);
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
599 else
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
600 smileys = get_proto_smileys(GAIM_PROTO_DEFAULT);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
601
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 while(smileys) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 GtkIMHtmlSmiley *smiley = smileys->data;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 if(!smiley->hidden) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 if(smiley_is_unique(unique_smileys, smiley))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 unique_smileys = g_slist_append(unique_smileys, smiley);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 smileys = smileys->next;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
610
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
611 GAIM_DIALOG(dialog);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
612
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
616
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
617 if(g_slist_length(unique_smileys)) {
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
618
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
619 width = floor(sqrt(g_slist_length(unique_smileys)));
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
620
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
621 smiley_table = gtk_table_new(width, width, TRUE);
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
622
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
623 /* pack buttons */
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
624
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
625 while(unique_smileys) {
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
626 GtkIMHtmlSmiley *smiley = unique_smileys->data;
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
627 if(!smiley->hidden) {
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
628 add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile);
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
629 if(++col >= width) {
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
630 col = 0;
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
631 row++;
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
632 }
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 }
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
634 unique_smileys = unique_smileys->next;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 }
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
636 }
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
637 else {
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
638 smiley_table = gtk_label_new(_("This theme has no available smileys."));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
640
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 gtk_container_add(GTK_CONTAINER(dialog), smiley_table);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
642
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 gtk_widget_show(smiley_table);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
644
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
646
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 /* connect signals */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 g_signal_connect(G_OBJECT(dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
650 G_CALLBACK(close_smiley_dialog), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
651
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 /* show everything */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 gtk_widget_show_all(dialog);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
655
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 toolbar->smiley_dialog = dialog;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
657
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 } else if (toolbar->smiley_dialog) {
8320
5c6c8d48946f [gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents: 8319
diff changeset
659 close_smiley_dialog(smiley, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
664 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
665 {
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
666 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bold), buttons & GTK_IMHTML_BOLD);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
667 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->italic), buttons & GTK_IMHTML_ITALIC);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
668 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->underline), buttons & GTK_IMHTML_UNDERLINE);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
669
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
670 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->larger_size), buttons & GTK_IMHTML_GROW);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
671 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smaller_size), buttons & GTK_IMHTML_SHRINK);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
672
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
673 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->font), buttons & GTK_IMHTML_FACE);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
674 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->fgcolor), buttons & GTK_IMHTML_FORECOLOR);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
675 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bgcolor), buttons & GTK_IMHTML_BACKCOLOR);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
676
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
677 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->image), buttons & GTK_IMHTML_IMAGE);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
678 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->link), buttons & GTK_IMHTML_LINK);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
679 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smiley), buttons & GTK_IMHTML_SMILEY);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
680 }
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
681
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
682 /* we call this when we want to _set_active the toggle button, it'll
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
683 * block the callback thats connected to the button so we don't have to
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
684 * do the double toggling hack
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
685 */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
686 static void toggle_button_set_active_block(GtkToggleButton *button,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
687 gboolean is_active,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
688 GtkIMHtmlToolbar *toolbar)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
689 {
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
690 GObject *object;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
691 g_return_if_fail(toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
692
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
693 object = g_object_ref(button);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
694 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
695 0, 0, NULL, NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
696 gtk_toggle_button_set_active(button, is_active);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
697 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
698 0, 0, NULL, NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
699 g_object_unref(object);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
700 }
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
701
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
702 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
703 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
704 if (buttons & GTK_IMHTML_BOLD)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
705 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
706 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
707 toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
708
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
709 if (buttons & GTK_IMHTML_ITALIC)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
710 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
711 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
712 toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
713
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
714 if (buttons & GTK_IMHTML_UNDERLINE)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
715 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
716 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
717 toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
718 }
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
719
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
720 static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
721 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
722 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)))
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
723 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), FALSE,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
724 toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
725
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
726 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)))
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
727 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
728 FALSE, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
729
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
730 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)))
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
731 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
732 FALSE, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
733 }
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
734
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
735 static void update_buttons(GtkIMHtmlToolbar *toolbar) {
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
736 gboolean bold, italic, underline;
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
737
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
738 bold = italic = underline = FALSE;
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
739 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml),
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
740 &bold, &italic, &underline);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
741
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
742 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)) != bold)
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
743 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
744 toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
745
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
746 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)) != italic)
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
747 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
748 toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
749
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
750 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)) != underline)
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
751 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
752 underline, toolbar);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
753 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
754
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
755 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) {
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
756 update_buttons(toolbar);
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
757 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
758
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
759 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location,
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
760 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar)
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
761 {
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
762 if(mark != gtk_text_buffer_get_insert(buffer))
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
763 return;
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
764
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
765 update_buttons(toolbar);
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
766 }
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
767
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 enum {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 LAST_SIGNAL
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 };
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 //static guint signals [LAST_SIGNAL] = { 0 };
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 gtk_imhtmltoolbar_finalize (GObject *object)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 {
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
776 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777
8685
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
778 if (toolbar->image_dialog != NULL)
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
779 {
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
780 gtk_widget_destroy(toolbar->image_dialog);
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
781 toolbar->image_dialog = NULL;
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
782 }
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
783
8785
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
784 if (toolbar->font_dialog != NULL)
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
785 {
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
786 gtk_widget_destroy(toolbar->font_dialog);
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
787 toolbar->font_dialog = NULL;
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
788 }
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
789
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
790 if (toolbar->smiley_dialog != NULL)
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
791 {
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
792 gtk_widget_destroy(toolbar->smiley_dialog);
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
793 toolbar->smiley_dialog = NULL;
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
794 }
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
795
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
796 if (toolbar->bgcolor_dialog != NULL)
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
797 {
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
798 gtk_widget_destroy(toolbar->bgcolor_dialog);
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
799 toolbar->bgcolor_dialog = NULL;
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
800 }
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
801
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
802 if (toolbar->fgcolor_dialog != NULL)
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
803 {
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
804 gtk_widget_destroy(toolbar->fgcolor_dialog);
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
805 toolbar->fgcolor_dialog = NULL;
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
806 }
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
807
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
808 if (toolbar->link_dialog != NULL)
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
809 {
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
810 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog);
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
811 toolbar->link_dialog = NULL;
a871dec1c9d6 [gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents: 8784
diff changeset
812 }
8784
48dd097eb475 [gaim-migrate @ 9546]
Christian Hammond <chipx86@chipx86.com>
parents: 8756
diff changeset
813
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
814 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
815 free(toolbar->sml);
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
816 gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
818 G_OBJECT_CLASS(parent_class)->finalize (object);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 /* Boring GTK stuff */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 GtkObjectClass *object_class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 GObjectClass *gobject_class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 object_class = (GtkObjectClass*) class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 gobject_class = (GObjectClass*) class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 parent_class = gtk_type_class(GTK_TYPE_VBOX);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 /* signals[URL_CLICKED] = g_signal_new(url_clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830 G_TYPE_FROM_CLASS(gobject_class),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 G_SIGNAL_RUN_FIRST,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 0,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 g_cclosure_marshal_VOID__POINTER,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 G_TYPE_NONE, 1,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 G_TYPE_POINTER);*/
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 gobject_class->finalize = gtk_imhtmltoolbar_finalize;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 GtkWidget *hbox;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 GtkWidget *button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 GtkWidget *sep;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 GtkSizeGroup *sg;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 toolbar->imhtml = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 toolbar->font_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 toolbar->fgcolor_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 toolbar->bgcolor_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 toolbar->smiley_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 toolbar->image_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 toolbar->tooltips = gtk_tooltips_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 sep = gtk_hseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 gtk_widget_show(sep);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 hbox = gtk_hbox_new(FALSE, 6);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 /* Bold */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 G_CALLBACK(do_bold), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 toolbar->bold = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 /* Italic */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 G_CALLBACK(do_italic), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 toolbar->italic = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 /* Underline */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 G_CALLBACK(do_underline), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 toolbar->underline = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 /* Increase font size */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 _("Larger font size"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 G_CALLBACK(do_big), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 toolbar->larger_size = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 /* Decrease font size */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 _("Smaller font size"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 G_CALLBACK(do_small), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 toolbar->smaller_size = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 /* Font Face */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 _("Font Face"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 G_CALLBACK(toggle_font), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 toolbar->font = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 /* Foreground Color */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 _("Foreground font color"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 G_CALLBACK(toggle_fg_color), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 toolbar->fgcolor = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 /* Background Color */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962 _("Background color"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 G_CALLBACK(toggle_bg_color), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967 toolbar->bgcolor = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 /* Insert Link */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 G_CALLBACK(insert_link_cb), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
980
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 toolbar->link = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 /* Insert IM Image */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert image"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 G_CALLBACK(insert_image_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 toolbar->image = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 /* Insert Smiley */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 G_CALLBACK(insert_smiley_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 toolbar->smiley = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 sep = gtk_hseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 gtk_widget_show(sep);
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1009 toolbar->sml = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 gtk_widget_show_all(hbox);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 GtkWidget *gtk_imhtmltoolbar_new()
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 GType gtk_imhtmltoolbar_get_type()
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 static GType imhtmltoolbar_type = 0;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 if (!imhtmltoolbar_type) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 static const GTypeInfo imhtmltoolbar_info = {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 sizeof(GtkIMHtmlToolbarClass),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 (GClassInitFunc) gtk_imhtmltoolbar_class_init,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 sizeof (GtkIMHtmlToolbar),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 0,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 (GInstanceInitFunc) gtk_imhtmltoolbar_init
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 };
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
1035 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_VBOX,
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 return imhtmltoolbar_type;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
1043 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 {
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1045 GtkIMHtmlButtons buttons;
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1046 gboolean bold, italic, underline;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1047
8325
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1048 g_return_if_fail(toolbar != NULL);
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1049 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar));
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1050 g_return_if_fail(imhtml != NULL);
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1051 g_return_if_fail(GTK_IS_IMHTML(imhtml));
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1052
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 toolbar->imhtml = imhtml;
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
1054 g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
1055 g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar);
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1056 g_signal_connect(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(reset_buttons_cb), toolbar);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
1057 g_signal_connect(G_OBJECT(imhtml), "format_function_update", G_CALLBACK(update_format_cb), toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
1058 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", G_CALLBACK(mark_set_cb), toolbar);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1059
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1060 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml));
8807
482fc53c969d [gaim-migrate @ 9569]
Mark Doliner <mark@kingant.net>
parents: 8788
diff changeset
1061 update_buttons_cb(GTK_IMHTML(imhtml), buttons, toolbar);
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1062
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1063 bold = italic = underline = FALSE;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1064
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
1065 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &underline);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1066
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1067 if(bold)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1068 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1069 toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1070
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1071 if(italic)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1072 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1073 toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1074
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1075 if(underline)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1076 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1077 underline, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 }
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1079
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1080 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1081 {
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1082 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1083 g_free(toolbar->sml);
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1084
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1085 toolbar->sml = g_strdup(proto_id);
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1086 }