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