Mercurial > pidgin
annotate src/gtkimhtmltoolbar.c @ 9131:4ae763960140
[gaim-migrate @ 9912]
Thanks to tszcheetah's bug 961232 I fixed the icon freezing problem.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 30 May 2004 20:34:14 +0000 |
parents | 812e7aa7eafa |
children | 2fa81d44ee6f |
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 //set_toggle(toolbar->image, FALSE); | |
437 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
438 return; | |
439 } | |
440 | |
441 name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget))); | |
442 | |
443 if (!name) { | |
444 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
445 return; | |
446 } | |
447 | |
448 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(widget))) { | |
449 g_free(name); | |
450 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
451 return; | |
452 } | |
453 | |
454 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
455 | |
456 if (!g_file_get_contents(name, &filedata, &size, &error)) { | |
457 gaim_notify_error(NULL, NULL, error->message, NULL); | |
458 | |
459 g_error_free(error); | |
460 g_free(name); | |
461 | |
462 return; | |
463 } | |
464 | |
465 filename = name; | |
466 while (strchr(filename, '/')) | |
467 filename = strchr(filename, '/') + 1; | |
468 | |
469 id = gaim_imgstore_add(filedata, size, filename); | |
470 g_free(filedata); | |
471 | |
472 if (!id) { | |
473 buf = g_strdup_printf(_("Failed to store image: %s\n"), name); | |
474 gaim_notify_error(NULL, NULL, buf, NULL); | |
475 | |
476 g_free(buf); | |
477 g_free(name); | |
478 | |
479 return; | |
480 } | |
481 | |
8962 | 482 ins = gtk_text_buffer_get_insert(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml))); |
483 gtk_text_buffer_get_iter_at_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)), | |
484 &iter, ins); | |
485 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(toolbar->imhtml), id, &iter); | |
486 gaim_imgstore_unref(id); | |
487 | |
8317 | 488 g_free(name); |
489 } | |
490 | |
491 | |
492 static void | |
493 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar) | |
494 { | |
495 char buf[BUF_LONG]; | |
496 GtkWidget *window; | |
497 | |
498 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) { | |
499 window = gtk_file_selection_new(_("Insert Image")); | |
500 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); | |
501 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
502 | |
503 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK); | |
504 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)), | |
505 "response", G_CALLBACK(do_insert_image_cb), toolbar); | |
506 | |
507 gtk_widget_show(window); | |
508 toolbar->image_dialog = window; | |
509 } else { | |
510 gtk_widget_destroy(toolbar->image_dialog); | |
511 toolbar->image_dialog = NULL; | |
512 } | |
513 gtk_widget_grab_focus(toolbar->imhtml); | |
514 } | |
515 | |
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 | 520 { |
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 | 525 gtk_widget_destroy(toolbar->smiley_dialog); |
526 toolbar->smiley_dialog = NULL; | |
527 } | |
528 } | |
529 | |
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 | 533 { |
9027 | 534 char *smiley_text, *escaped_smiley; |
535 | |
536 smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | |
537 escaped_smiley = gaim_escape_html(smiley_text); | |
8317 | 538 |
8456 | 539 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml), |
540 GTK_IMHTML(toolbar->imhtml)->protocol_name, | |
9027 | 541 escaped_smiley); |
8317 | 542 |
9027 | 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 | 545 } |
546 | |
547 | |
548 static void add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face) | |
549 { | |
550 GtkWidget *image; | |
551 GtkWidget *button; | |
552 | |
553 image = gtk_image_new_from_file(filename); | |
554 button = gtk_button_new(); | |
555 gtk_container_add(GTK_CONTAINER(button), image); | |
556 g_object_set_data(G_OBJECT(button), "smiley_text", face); | |
557 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar); | |
558 | |
559 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL); | |
560 | |
561 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1); | |
562 | |
563 /* these look really weird with borders */ | |
564 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
565 | |
566 gtk_widget_show(button); | |
567 } | |
568 | |
569 | |
570 static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) { | |
571 while(list) { | |
572 GtkIMHtmlSmiley *cur = list->data; | |
573 if(!strcmp(cur->file, smiley->file)) | |
574 return FALSE; | |
575 list = list->next; | |
576 } | |
577 return TRUE; | |
578 } | |
579 | |
580 | |
581 static void | |
582 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar) | |
583 { | |
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 | 586 GtkWidget *dialog; |
587 GtkWidget *smiley_table = NULL; | |
588 GSList *smileys, *unique_smileys = NULL; | |
589 int width; | |
590 int row = 0, col = 0; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
591 |
8317 | 592 if (toolbar->smiley_dialog) { |
593 gtk_widget_grab_focus(toolbar->imhtml); | |
594 return; | |
595 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
596 |
8427 | 597 if (toolbar->sml) |
598 smileys = get_proto_smileys(toolbar->sml); | |
8892 | 599 else |
600 smileys = get_proto_smileys(GAIM_PROTO_DEFAULT); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
601 |
8317 | 602 while(smileys) { |
603 GtkIMHtmlSmiley *smiley = smileys->data; | |
604 if(!smiley->hidden) { | |
605 if(smiley_is_unique(unique_smileys, smiley)) | |
606 unique_smileys = g_slist_append(unique_smileys, smiley); | |
607 } | |
608 smileys = smileys->next; | |
609 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
610 |
8892 | 611 GAIM_DIALOG(dialog); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
612 |
8317 | 613 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
614 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); | |
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 | 617 if(g_slist_length(unique_smileys)) { |
618 | |
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 | 621 smiley_table = gtk_table_new(width, width, TRUE); |
622 | |
623 /* pack buttons */ | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
624 |
8892 | 625 while(unique_smileys) { |
626 GtkIMHtmlSmiley *smiley = unique_smileys->data; | |
627 if(!smiley->hidden) { | |
628 add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile); | |
629 if(++col >= width) { | |
630 col = 0; | |
631 row++; | |
632 } | |
8317 | 633 } |
8892 | 634 unique_smileys = unique_smileys->next; |
8317 | 635 } |
8892 | 636 } |
637 else { | |
638 smiley_table = gtk_label_new(_("This theme has no available smileys.")); | |
8317 | 639 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
640 |
8317 | 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 | 643 gtk_widget_show(smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
644 |
8317 | 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 | 647 /* connect signals */ |
648 g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog"); | |
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 | 652 /* show everything */ |
653 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!")); | |
654 gtk_widget_show_all(dialog); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
655 |
8317 | 656 toolbar->smiley_dialog = dialog; |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
657 |
8317 | 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 | 660 } |
661 gtk_widget_grab_focus(toolbar->imhtml); | |
662 } | |
663 | |
8420 | 664 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) |
665 { | |
666 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bold), buttons & GTK_IMHTML_BOLD); | |
667 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->italic), buttons & GTK_IMHTML_ITALIC); | |
668 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->underline), buttons & GTK_IMHTML_UNDERLINE); | |
669 | |
670 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->larger_size), buttons & GTK_IMHTML_GROW); | |
671 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smaller_size), buttons & GTK_IMHTML_SHRINK); | |
672 | |
673 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->font), buttons & GTK_IMHTML_FACE); | |
674 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->fgcolor), buttons & GTK_IMHTML_FORECOLOR); | |
675 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bgcolor), buttons & GTK_IMHTML_BACKCOLOR); | |
676 | |
677 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->image), buttons & GTK_IMHTML_IMAGE); | |
678 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->link), buttons & GTK_IMHTML_LINK); | |
679 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smiley), buttons & GTK_IMHTML_SMILEY); | |
8481 | 680 } |
8420 | 681 |
8481 | 682 /* we call this when we want to _set_active the toggle button, it'll |
683 * block the callback thats connected to the button so we don't have to | |
684 * do the double toggling hack | |
685 */ | |
686 static void toggle_button_set_active_block(GtkToggleButton *button, | |
687 gboolean is_active, | |
688 GtkIMHtmlToolbar *toolbar) | |
689 { | |
690 GObject *object; | |
691 g_return_if_fail(toolbar); | |
692 | |
693 object = g_object_ref(button); | |
694 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, | |
695 0, 0, NULL, NULL, toolbar); | |
696 gtk_toggle_button_set_active(button, is_active); | |
697 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, | |
698 0, 0, NULL, NULL, toolbar); | |
699 g_object_unref(object); | |
8420 | 700 } |
701 | |
702 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) | |
703 { | |
8481 | 704 if (buttons & GTK_IMHTML_BOLD) |
705 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), | |
706 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)), | |
707 toolbar); | |
8420 | 708 |
8481 | 709 if (buttons & GTK_IMHTML_ITALIC) |
710 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), | |
711 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)), | |
712 toolbar); | |
8420 | 713 |
8481 | 714 if (buttons & GTK_IMHTML_UNDERLINE) |
715 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
716 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)), | |
717 toolbar); | |
8420 | 718 } |
719 | |
8427 | 720 static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) |
721 { | |
8481 | 722 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold))) |
723 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), FALSE, | |
724 toolbar); | |
725 | |
726 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic))) | |
727 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), | |
728 FALSE, toolbar); | |
729 | |
730 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline))) | |
731 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
732 FALSE, toolbar); | |
733 } | |
8516 | 734 |
735 static void update_buttons(GtkIMHtmlToolbar *toolbar) { | |
8506 | 736 gboolean bold, italic, underline; |
737 | |
738 bold = italic = underline = FALSE; | |
8516 | 739 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml), |
740 &bold, &italic, &underline); | |
8506 | 741 |
742 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)) != bold) | |
743 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, | |
744 toolbar); | |
8516 | 745 |
8506 | 746 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)) != italic) |
747 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, | |
748 toolbar); | |
8516 | 749 |
8506 | 750 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)) != underline) |
751 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
8677 | 752 underline, toolbar); |
8506 | 753 } |
8481 | 754 |
8516 | 755 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) { |
756 update_buttons(toolbar); | |
757 } | |
8481 | 758 |
8516 | 759 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location, |
760 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar) | |
761 { | |
762 if(mark != gtk_text_buffer_get_insert(buffer)) | |
763 return; | |
764 | |
765 update_buttons(toolbar); | |
8427 | 766 } |
767 | |
8317 | 768 enum { |
769 LAST_SIGNAL | |
770 }; | |
771 //static guint signals [LAST_SIGNAL] = { 0 }; | |
772 | |
773 static void | |
774 gtk_imhtmltoolbar_finalize (GObject *object) | |
775 { | |
8391 | 776 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object); |
8317 | 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 | 814 if (toolbar->sml) |
815 free(toolbar->sml); | |
8391 | 816 gtk_object_sink(GTK_OBJECT(toolbar->tooltips)); |
8317 | 817 |
8391 | 818 G_OBJECT_CLASS(parent_class)->finalize (object); |
8317 | 819 } |
820 | |
821 /* Boring GTK stuff */ | |
822 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class) | |
823 { | |
824 GtkObjectClass *object_class; | |
825 GObjectClass *gobject_class; | |
826 object_class = (GtkObjectClass*) class; | |
827 gobject_class = (GObjectClass*) class; | |
828 parent_class = gtk_type_class(GTK_TYPE_VBOX); | |
829 /* signals[URL_CLICKED] = g_signal_new(url_clicked", | |
830 G_TYPE_FROM_CLASS(gobject_class), | |
831 G_SIGNAL_RUN_FIRST, | |
832 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
833 NULL, | |
834 0, | |
835 g_cclosure_marshal_VOID__POINTER, | |
836 G_TYPE_NONE, 1, | |
837 G_TYPE_POINTER);*/ | |
838 gobject_class->finalize = gtk_imhtmltoolbar_finalize; | |
839 } | |
840 | |
841 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar) | |
842 { | |
843 GtkWidget *hbox; | |
844 GtkWidget *button; | |
845 GtkWidget *sep; | |
846 GtkSizeGroup *sg; | |
847 | |
848 toolbar->imhtml = NULL; | |
849 toolbar->font_dialog = NULL; | |
850 toolbar->fgcolor_dialog = NULL; | |
851 toolbar->bgcolor_dialog = NULL; | |
852 toolbar->link_dialog = NULL; | |
853 toolbar->smiley_dialog = NULL; | |
854 toolbar->image_dialog = NULL; | |
855 | |
856 toolbar->tooltips = gtk_tooltips_new(); | |
857 | |
858 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
859 | |
860 sep = gtk_hseparator_new(); | |
861 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
862 gtk_widget_show(sep); | |
863 | |
864 hbox = gtk_hbox_new(FALSE, 6); | |
865 gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0); | |
866 | |
867 /* Bold */ | |
868 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
869 gtk_size_group_add_widget(sg, button); | |
870 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
871 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL); | |
872 | |
873 g_signal_connect(G_OBJECT(button), "clicked", | |
874 G_CALLBACK(do_bold), toolbar); | |
875 | |
876 toolbar->bold = button; | |
877 | |
878 /* Italic */ | |
879 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
880 gtk_size_group_add_widget(sg, button); | |
881 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
882 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL); | |
883 | |
884 g_signal_connect(G_OBJECT(button), "clicked", | |
885 G_CALLBACK(do_italic), toolbar); | |
886 | |
887 toolbar->italic = button; | |
888 | |
889 /* Underline */ | |
890 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
891 gtk_size_group_add_widget(sg, button); | |
892 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
893 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL); | |
894 | |
895 g_signal_connect(G_OBJECT(button), "clicked", | |
896 G_CALLBACK(do_underline), toolbar); | |
897 | |
898 toolbar->underline = button; | |
899 | |
900 /* Sep */ | |
901 sep = gtk_vseparator_new(); | |
902 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
903 | |
904 /* Increase font size */ | |
905 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
906 gtk_size_group_add_widget(sg, button); | |
907 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
908 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
909 _("Larger font size"), NULL); | |
910 | |
911 g_signal_connect(G_OBJECT(button), "clicked", | |
912 G_CALLBACK(do_big), toolbar); | |
913 | |
914 toolbar->larger_size = button; | |
915 | |
916 /* Decrease font size */ | |
917 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
918 gtk_size_group_add_widget(sg, button); | |
919 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
920 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
921 _("Smaller font size"), NULL); | |
922 | |
923 g_signal_connect(G_OBJECT(button), "clicked", | |
924 G_CALLBACK(do_small), toolbar); | |
925 | |
926 toolbar->smaller_size = button; | |
927 | |
928 /* Sep */ | |
929 sep = gtk_vseparator_new(); | |
930 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
931 | |
932 /* Font Face */ | |
933 | |
934 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
935 gtk_size_group_add_widget(sg, button); | |
936 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
937 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
938 _("Font Face"), NULL); | |
939 | |
940 g_signal_connect(G_OBJECT(button), "clicked", | |
941 G_CALLBACK(toggle_font), toolbar); | |
942 | |
943 toolbar->font = button; | |
944 | |
945 /* Foreground Color */ | |
946 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
947 gtk_size_group_add_widget(sg, button); | |
948 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
949 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
950 _("Foreground font color"), NULL); | |
951 | |
952 g_signal_connect(G_OBJECT(button), "clicked", | |
953 G_CALLBACK(toggle_fg_color), toolbar); | |
954 | |
955 toolbar->fgcolor = button; | |
956 | |
957 /* Background Color */ | |
958 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
959 gtk_size_group_add_widget(sg, button); | |
960 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
961 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
962 _("Background color"), NULL); | |
963 | |
964 g_signal_connect(G_OBJECT(button), "clicked", | |
965 G_CALLBACK(toggle_bg_color), toolbar); | |
966 | |
967 toolbar->bgcolor = button; | |
968 | |
969 /* Sep */ | |
970 sep = gtk_vseparator_new(); | |
971 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
972 | |
973 /* Insert Link */ | |
974 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
975 gtk_size_group_add_widget(sg, button); | |
976 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
977 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL); | |
978 g_signal_connect(G_OBJECT(button), "clicked", | |
979 G_CALLBACK(insert_link_cb), toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
980 |
8317 | 981 toolbar->link = button; |
982 | |
983 /* Insert IM Image */ | |
984 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
985 gtk_size_group_add_widget(sg, button); | |
986 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
987 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert image"), NULL); | |
988 | |
989 g_signal_connect(G_OBJECT(button), "clicked", | |
990 G_CALLBACK(insert_image_cb), toolbar); | |
991 | |
992 toolbar->image = button; | |
993 | |
994 /* Insert Smiley */ | |
995 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
996 gtk_size_group_add_widget(sg, button); | |
997 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
998 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL); | |
999 | |
1000 g_signal_connect(G_OBJECT(button), "clicked", | |
1001 G_CALLBACK(insert_smiley_cb), toolbar); | |
1002 | |
1003 toolbar->smiley = button; | |
1004 | |
1005 | |
1006 sep = gtk_hseparator_new(); | |
1007 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
1008 gtk_widget_show(sep); | |
8427 | 1009 toolbar->sml = NULL; |
8317 | 1010 gtk_widget_show_all(hbox); |
1011 } | |
1012 | |
1013 GtkWidget *gtk_imhtmltoolbar_new() | |
1014 { | |
1015 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL)); | |
1016 } | |
1017 | |
1018 GType gtk_imhtmltoolbar_get_type() | |
1019 { | |
1020 static GType imhtmltoolbar_type = 0; | |
1021 | |
1022 if (!imhtmltoolbar_type) { | |
1023 static const GTypeInfo imhtmltoolbar_info = { | |
1024 sizeof(GtkIMHtmlToolbarClass), | |
1025 NULL, | |
1026 NULL, | |
1027 (GClassInitFunc) gtk_imhtmltoolbar_class_init, | |
1028 NULL, | |
1029 NULL, | |
1030 sizeof (GtkIMHtmlToolbar), | |
1031 0, | |
1032 (GInstanceInitFunc) gtk_imhtmltoolbar_init | |
1033 }; | |
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 | 1036 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0); |
1037 } | |
1038 | |
1039 return imhtmltoolbar_type; | |
1040 } | |
1041 | |
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 | 1044 { |
8788 | 1045 GtkIMHtmlButtons buttons; |
8481 | 1046 gboolean bold, italic, underline; |
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 | 1053 toolbar->imhtml = imhtml; |
8506 | 1054 g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar); |
8420 | 1055 g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar); |
8427 | 1056 g_signal_connect(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(reset_buttons_cb), toolbar); |
8506 | 1057 g_signal_connect(G_OBJECT(imhtml), "format_function_update", G_CALLBACK(update_format_cb), toolbar); |
8516 | 1058 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", G_CALLBACK(mark_set_cb), toolbar); |
8481 | 1059 |
8788 | 1060 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)); |
8807 | 1061 update_buttons_cb(GTK_IMHTML(imhtml), buttons, toolbar); |
8788 | 1062 |
8481 | 1063 bold = italic = underline = FALSE; |
1064 | |
8516 | 1065 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &underline); |
8481 | 1066 |
1067 if(bold) | |
1068 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, | |
1069 toolbar); | |
1070 | |
1071 if(italic) | |
1072 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, | |
1073 toolbar); | |
1074 | |
1075 if(underline) | |
1076 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
1077 underline, toolbar); | |
8317 | 1078 } |
8427 | 1079 |
1080 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id) | |
1081 { | |
1082 if (toolbar->sml) | |
1083 g_free(toolbar->sml); | |
1084 | |
1085 toolbar->sml = g_strdup(proto_id); | |
1086 } |