Mercurial > pidgin.yaz
annotate src/gtkimhtmltoolbar.c @ 8788:262f81346c0a
[gaim-migrate @ 9550]
Disable the insert image button on the create away message dialog.
I also made the toolbar grab which format options it should support
when it is attached to the imhtml. So you can set if the imhtml
should support smileys, images, background colors, etc and THEN
attach the toolbar and the buttons will still be correctly grayed out.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 24 Apr 2004 01:43:11 +0000 |
parents | a871dec1c9d6 |
children | 482fc53c969d |
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 { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
156 #if 0 |
8317 | 157 char fonttif[128]; |
158 const char *fontface; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
159 #endif |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
160 |
8317 | 161 g_return_if_fail(toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
162 |
8317 | 163 if (!toolbar->font_dialog) { |
164 toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font")); | |
165 | |
166 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
|
167 |
8317 | 168 /* if (gtkconv->fontface[0]) { |
169 g_snprintf(fonttif, sizeof(fonttif), "%s 12", gtkconv->fontface); | |
170 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font), | |
171 fonttif); | |
172 } else { | |
173 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font), | |
174 DEFAULT_FONT_FACE); | |
175 } | |
176 */ | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
177 |
8317 | 178 g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
179 G_CALLBACK(destroy_toolbar_font), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
180 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
|
181 G_CALLBACK(apply_font), toolbar->font_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
182 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
|
183 G_CALLBACK(cancel_toolbar_font), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
184 |
8317 | 185 gtk_window_present(GTK_WINDOW(toolbar->font_dialog)); |
186 } else { | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
187 cancel_toolbar_font(NULL, toolbar); |
8317 | 188 } |
189 gtk_widget_grab_focus(toolbar->imhtml); | |
190 } | |
191 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
192 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
193 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
194 GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
195 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
196 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->fgcolor), FALSE); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
197 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
198 if (toolbar->fgcolor_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
199 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
200 gtk_widget_destroy(toolbar->fgcolor_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
201 toolbar->fgcolor_dialog = NULL; |
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 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
205 static void cancel_toolbar_fgcolor(GtkWidget *widget, |
8321
eb269b81fff8
[gaim-migrate @ 9045]
Christian Hammond <chipx86@chipx86.com>
parents:
8320
diff
changeset
|
206 GtkIMHtmlToolbar *toolbar) |
8317 | 207 { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
208 destroy_toolbar_fgcolor(widget, NULL, toolbar); |
8317 | 209 } |
210 | |
211 static void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
212 { | |
213 GdkColor text_color; | |
214 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar"); | |
215 char *open_tag; | |
216 | |
217 open_tag = g_malloc(30); | |
218 gtk_color_selection_get_current_color(colorsel, &text_color); | |
219 g_snprintf(open_tag, 23, "#%02X%02X%02X", | |
220 text_color.red / 256, | |
221 text_color.green / 256, | |
222 text_color.blue / 256); | |
223 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag); | |
224 | |
225 g_free(open_tag); | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
226 cancel_toolbar_fgcolor(NULL, toolbar); |
8317 | 227 } |
228 | |
229 static void | |
230 toggle_fg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar) | |
231 { | |
232 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) { | |
233 GtkWidget *colorsel; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
234 /* GdkColor fgcolor; */ |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
235 |
8317 | 236 /*gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
237 &fgcolor);*/ | |
238 if (!toolbar->fgcolor_dialog) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
239 |
8317 | 240 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); |
241 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->colorsel; | |
242 //gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor); | |
243 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
244 |
8317 | 245 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
246 G_CALLBACK(destroy_toolbar_fgcolor), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
247 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
|
248 G_CALLBACK(do_fgcolor), colorsel); |
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)->cancel_button), "clicked", |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
250 G_CALLBACK(cancel_toolbar_fgcolor), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
251 |
8317 | 252 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
253 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog)); |
8317 | 254 } else if (toolbar->fgcolor_dialog != NULL) { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
255 cancel_toolbar_fgcolor(color, toolbar); |
8317 | 256 } else { |
257 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
258 } | |
259 gtk_widget_grab_focus(toolbar->imhtml); | |
260 } | |
261 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
262 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
263 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
264 GtkIMHtmlToolbar *toolbar) |
8317 | 265 { |
266 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
|
267 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
268 if (toolbar->bgcolor_dialog != NULL) |
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 gtk_widget_destroy(toolbar->bgcolor_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
271 toolbar->bgcolor_dialog = NULL; |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
272 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
273 } |
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 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
276 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
277 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
278 destroy_toolbar_bgcolor(widget, NULL, toolbar); |
8317 | 279 } |
280 | |
281 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
282 { | |
283 GdkColor text_color; | |
284 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar"); | |
285 char *open_tag; | |
286 | |
287 open_tag = g_malloc(30); | |
288 gtk_color_selection_get_current_color(colorsel, &text_color); | |
289 g_snprintf(open_tag, 23, "#%02X%02X%02X", | |
290 text_color.red / 256, | |
291 text_color.green / 256, | |
292 text_color.blue / 256); | |
293 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag); | |
294 | |
295 g_free(open_tag); | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
296 cancel_toolbar_bgcolor(NULL, toolbar); |
8317 | 297 } |
298 | |
299 static void | |
300 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar) | |
301 { | |
302 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) { | |
303 GtkWidget *colorsel; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
304 /* GdkColor bgcolor; */ |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
305 |
8317 | 306 /*gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
307 &bgcolor);*/ | |
308 if (!toolbar->bgcolor_dialog) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
309 |
8359 | 310 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color")); |
8317 | 311 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->colorsel; |
312 //gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor); | |
313 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
314 |
8317 | 315 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
316 G_CALLBACK(destroy_toolbar_bgcolor), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
317 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
|
318 G_CALLBACK(do_bgcolor), colorsel); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
319 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
|
320 G_CALLBACK(cancel_toolbar_bgcolor), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
321 |
8317 | 322 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
323 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog)); |
8317 | 324 } else if (toolbar->bgcolor_dialog != NULL) { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
325 cancel_toolbar_bgcolor(color, toolbar); |
8317 | 326 } else { |
327 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
328 } | |
329 gtk_widget_grab_focus(toolbar->imhtml); | |
330 } | |
331 | |
332 static void | |
333 cancel_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields) | |
334 { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
335 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
|
336 |
8317 | 337 toolbar->link_dialog = NULL; |
338 } | |
339 | |
340 static void | |
341 close_link_dialog(GtkIMHtmlToolbar *toolbar) | |
342 { | |
343 if (toolbar->link_dialog != NULL) | |
344 { | |
345 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog); | |
346 toolbar->link_dialog = NULL; | |
347 } | |
348 } | |
349 | |
350 static void | |
351 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields) | |
352 { | |
353 const char *url, *description; | |
354 | |
355 url = gaim_request_fields_get_string(fields, "url"); | |
356 description = gaim_request_fields_get_string(fields, "description"); | |
357 | |
358 if (description == NULL) | |
359 description = url; | |
360 | |
8677 | 361 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml), |
362 gtk_text_buffer_get_insert(GTK_IMHTML(toolbar->imhtml)->text_buffer), | |
363 url, description); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
364 |
8317 | 365 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE); |
366 | |
367 toolbar->link_dialog = NULL; | |
368 } | |
369 | |
370 static void | |
371 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar) | |
372 { | |
373 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) { | |
374 GaimRequestFields *fields; | |
375 GaimRequestFieldGroup *group; | |
376 GaimRequestField *field; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
377 |
8317 | 378 fields = gaim_request_fields_new(); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
379 |
8317 | 380 group = gaim_request_field_group_new(NULL); |
381 gaim_request_fields_add_group(fields, group); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
382 |
8317 | 383 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE); |
384 gaim_request_field_set_required(field, TRUE); | |
385 gaim_request_field_group_add_field(group, field); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
386 |
8317 | 387 field = gaim_request_field_string_new("description", _("_Description"), |
388 NULL, FALSE); | |
389 gaim_request_field_group_add_field(group, field); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
390 |
8317 | 391 toolbar->link_dialog = |
392 gaim_request_fields(toolbar, _("Insert Link"), | |
393 NULL, | |
394 _("Please enter the URL and description of the " | |
395 "link that you want to insert. The description " | |
396 "is optional."), | |
397 fields, | |
398 _("_Insert"), G_CALLBACK(do_insert_link_cb), | |
399 _("Cancel"), G_CALLBACK(cancel_link_cb), | |
400 toolbar); | |
8322
ffb601c6b833
[gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents:
8321
diff
changeset
|
401 } else { |
8317 | 402 close_link_dialog(toolbar); |
403 } | |
404 gtk_widget_grab_focus(toolbar->imhtml); | |
405 } | |
406 | |
407 | |
408 static void | |
409 do_insert_image_cb(GtkWidget *widget, int resp, GtkIMHtmlToolbar *toolbar) | |
410 { | |
411 char *name, *filename; | |
412 char *buf, *filedata; | |
413 size_t size; | |
414 GError *error = NULL; | |
415 int id; | |
416 | |
417 if (resp != GTK_RESPONSE_OK) { | |
418 //set_toggle(toolbar->image, FALSE); | |
419 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
420 return; | |
421 } | |
422 | |
423 name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget))); | |
424 | |
425 if (!name) { | |
426 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
427 return; | |
428 } | |
429 | |
430 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(widget))) { | |
431 g_free(name); | |
432 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
433 return; | |
434 } | |
435 | |
436 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
437 | |
438 if (!g_file_get_contents(name, &filedata, &size, &error)) { | |
439 gaim_notify_error(NULL, NULL, error->message, NULL); | |
440 | |
441 g_error_free(error); | |
442 g_free(name); | |
443 | |
444 return; | |
445 } | |
446 | |
447 filename = name; | |
448 while (strchr(filename, '/')) | |
449 filename = strchr(filename, '/') + 1; | |
450 | |
451 id = gaim_imgstore_add(filedata, size, filename); | |
452 g_free(filedata); | |
453 | |
454 if (!id) { | |
455 buf = g_strdup_printf(_("Failed to store image: %s\n"), name); | |
456 gaim_notify_error(NULL, NULL, buf, NULL); | |
457 | |
458 g_free(buf); | |
459 g_free(name); | |
460 | |
461 return; | |
462 } | |
463 | |
464 //im->images = g_slist_append(im->images, GINT_TO_POINTER(id)); | |
465 | |
466 /*buf = g_strdup_printf("<IMG ID=\"%d\" SRC=\"file://%s\">", id, filename); | |
467 gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), buf, -1); | |
468 g_free(buf); | |
469 */ | |
470 g_free(name); | |
471 } | |
472 | |
473 | |
474 static void | |
475 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar) | |
476 { | |
477 char buf[BUF_LONG]; | |
478 GtkWidget *window; | |
479 | |
480 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) { | |
481 window = gtk_file_selection_new(_("Insert Image")); | |
482 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); | |
483 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
484 | |
485 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK); | |
486 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)), | |
487 "response", G_CALLBACK(do_insert_image_cb), toolbar); | |
488 | |
489 gtk_widget_show(window); | |
490 toolbar->image_dialog = window; | |
491 } else { | |
492 gtk_widget_destroy(toolbar->image_dialog); | |
493 toolbar->image_dialog = NULL; | |
494 } | |
495 gtk_widget_grab_focus(toolbar->imhtml); | |
496 } | |
497 | |
498 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
499 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
500 close_smiley_dialog(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
501 GtkIMHtmlToolbar *toolbar) |
8317 | 502 { |
503 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
|
504 |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
505 if (toolbar->smiley_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
506 { |
8317 | 507 gtk_widget_destroy(toolbar->smiley_dialog); |
508 toolbar->smiley_dialog = NULL; | |
509 } | |
510 } | |
511 | |
512 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
513 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
514 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
8317 | 515 { |
516 char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | |
517 | |
8456 | 518 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml), |
519 GTK_IMHTML(toolbar->imhtml)->protocol_name, | |
520 smiley_text); | |
8317 | 521 |
8320
5c6c8d48946f
[gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
522 close_smiley_dialog(NULL, NULL, toolbar); |
8317 | 523 } |
524 | |
525 | |
526 static void add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face) | |
527 { | |
528 GtkWidget *image; | |
529 GtkWidget *button; | |
530 | |
531 image = gtk_image_new_from_file(filename); | |
532 button = gtk_button_new(); | |
533 gtk_container_add(GTK_CONTAINER(button), image); | |
534 g_object_set_data(G_OBJECT(button), "smiley_text", face); | |
535 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar); | |
536 | |
537 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL); | |
538 | |
539 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1); | |
540 | |
541 /* these look really weird with borders */ | |
542 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
543 | |
544 gtk_widget_show(button); | |
545 } | |
546 | |
547 | |
548 static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) { | |
549 while(list) { | |
550 GtkIMHtmlSmiley *cur = list->data; | |
551 if(!strcmp(cur->file, smiley->file)) | |
552 return FALSE; | |
553 list = list->next; | |
554 } | |
555 return TRUE; | |
556 } | |
557 | |
558 | |
559 static void | |
560 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar) | |
561 { | |
562 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
563 |
8317 | 564 GtkWidget *dialog; |
565 GtkWidget *smiley_table = NULL; | |
566 GSList *smileys, *unique_smileys = NULL; | |
567 int width; | |
568 int row = 0, col = 0; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
569 |
8317 | 570 if (toolbar->smiley_dialog) { |
571 gtk_widget_grab_focus(toolbar->imhtml); | |
572 return; | |
573 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
574 |
8427 | 575 if (toolbar->sml) |
576 smileys = get_proto_smileys(toolbar->sml); | |
8317 | 577 else |
8427 | 578 smileys = get_proto_smileys(GAIM_PROTO_DEFAULT); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
579 |
8317 | 580 while(smileys) { |
581 GtkIMHtmlSmiley *smiley = smileys->data; | |
582 if(!smiley->hidden) { | |
583 if(smiley_is_unique(unique_smileys, smiley)) | |
584 unique_smileys = g_slist_append(unique_smileys, smiley); | |
585 } | |
586 smileys = smileys->next; | |
587 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
588 |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
589 |
8317 | 590 width = floor(sqrt(g_slist_length(unique_smileys))); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
591 |
8317 | 592 GAIM_DIALOG(dialog); |
593 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
594 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); | |
595 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
|
596 |
8317 | 597 smiley_table = gtk_table_new(width, width, TRUE); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
598 |
8317 | 599 /* pack buttons */ |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
600 |
8317 | 601 while(unique_smileys) { |
602 GtkIMHtmlSmiley *smiley = unique_smileys->data; | |
603 if(!smiley->hidden) { | |
604 add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile); | |
605 if(++col >= width) { | |
606 col = 0; | |
607 row++; | |
608 } | |
609 } | |
610 unique_smileys = unique_smileys->next; | |
611 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
612 |
8317 | 613 gtk_container_add(GTK_CONTAINER(dialog), smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
614 |
8317 | 615 gtk_widget_show(smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
616 |
8317 | 617 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
618 |
8317 | 619 /* connect signals */ |
620 g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog"); | |
621 g_signal_connect(G_OBJECT(dialog), "delete_event", | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
622 G_CALLBACK(close_smiley_dialog), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
623 |
8317 | 624 /* show everything */ |
625 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!")); | |
626 gtk_widget_show_all(dialog); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
627 |
8317 | 628 toolbar->smiley_dialog = dialog; |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
629 |
8317 | 630 } else if (toolbar->smiley_dialog) { |
8320
5c6c8d48946f
[gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
631 close_smiley_dialog(smiley, NULL, toolbar); |
8317 | 632 } |
633 gtk_widget_grab_focus(toolbar->imhtml); | |
634 } | |
635 | |
8420 | 636 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) |
637 { | |
638 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bold), buttons & GTK_IMHTML_BOLD); | |
639 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->italic), buttons & GTK_IMHTML_ITALIC); | |
640 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->underline), buttons & GTK_IMHTML_UNDERLINE); | |
641 | |
642 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->larger_size), buttons & GTK_IMHTML_GROW); | |
643 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smaller_size), buttons & GTK_IMHTML_SHRINK); | |
644 | |
645 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->font), buttons & GTK_IMHTML_FACE); | |
646 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->fgcolor), buttons & GTK_IMHTML_FORECOLOR); | |
647 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bgcolor), buttons & GTK_IMHTML_BACKCOLOR); | |
648 | |
649 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->image), buttons & GTK_IMHTML_IMAGE); | |
650 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->link), buttons & GTK_IMHTML_LINK); | |
651 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smiley), buttons & GTK_IMHTML_SMILEY); | |
8481 | 652 } |
8420 | 653 |
8481 | 654 /* we call this when we want to _set_active the toggle button, it'll |
655 * block the callback thats connected to the button so we don't have to | |
656 * do the double toggling hack | |
657 */ | |
658 static void toggle_button_set_active_block(GtkToggleButton *button, | |
659 gboolean is_active, | |
660 GtkIMHtmlToolbar *toolbar) | |
661 { | |
662 GObject *object; | |
663 g_return_if_fail(toolbar); | |
664 | |
665 object = g_object_ref(button); | |
666 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, | |
667 0, 0, NULL, NULL, toolbar); | |
668 gtk_toggle_button_set_active(button, is_active); | |
669 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, | |
670 0, 0, NULL, NULL, toolbar); | |
671 g_object_unref(object); | |
8420 | 672 } |
673 | |
674 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) | |
675 { | |
8481 | 676 if (buttons & GTK_IMHTML_BOLD) |
677 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), | |
678 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)), | |
679 toolbar); | |
8420 | 680 |
8481 | 681 if (buttons & GTK_IMHTML_ITALIC) |
682 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), | |
683 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)), | |
684 toolbar); | |
8420 | 685 |
8481 | 686 if (buttons & GTK_IMHTML_UNDERLINE) |
687 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
688 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)), | |
689 toolbar); | |
8420 | 690 } |
691 | |
8427 | 692 static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) |
693 { | |
8481 | 694 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold))) |
695 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), FALSE, | |
696 toolbar); | |
697 | |
698 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic))) | |
699 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), | |
700 FALSE, toolbar); | |
701 | |
702 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline))) | |
703 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
704 FALSE, toolbar); | |
705 } | |
8516 | 706 |
707 static void update_buttons(GtkIMHtmlToolbar *toolbar) { | |
8506 | 708 gboolean bold, italic, underline; |
709 | |
710 bold = italic = underline = FALSE; | |
8516 | 711 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml), |
712 &bold, &italic, &underline); | |
8506 | 713 |
714 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)) != bold) | |
715 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, | |
716 toolbar); | |
8516 | 717 |
8506 | 718 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)) != italic) |
719 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, | |
720 toolbar); | |
8516 | 721 |
8506 | 722 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)) != underline) |
723 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
8677 | 724 underline, toolbar); |
8506 | 725 } |
8481 | 726 |
8516 | 727 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) { |
728 update_buttons(toolbar); | |
729 } | |
8481 | 730 |
8516 | 731 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location, |
732 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar) | |
733 { | |
734 if(mark != gtk_text_buffer_get_insert(buffer)) | |
735 return; | |
736 | |
737 update_buttons(toolbar); | |
8427 | 738 } |
739 | |
8317 | 740 enum { |
741 LAST_SIGNAL | |
742 }; | |
743 //static guint signals [LAST_SIGNAL] = { 0 }; | |
744 | |
745 static void | |
746 gtk_imhtmltoolbar_finalize (GObject *object) | |
747 { | |
8391 | 748 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object); |
8317 | 749 |
8685
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
750 if (toolbar->image_dialog != NULL) |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
751 { |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
752 gtk_widget_destroy(toolbar->image_dialog); |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
753 toolbar->image_dialog = NULL; |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
754 } |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
755 |
8785
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
756 if (toolbar->font_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
757 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
758 gtk_widget_destroy(toolbar->font_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
759 toolbar->font_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
760 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
761 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
762 if (toolbar->smiley_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
763 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
764 gtk_widget_destroy(toolbar->smiley_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
765 toolbar->smiley_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
766 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
767 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
768 if (toolbar->bgcolor_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
769 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
770 gtk_widget_destroy(toolbar->bgcolor_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
771 toolbar->bgcolor_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
772 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
773 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
774 if (toolbar->fgcolor_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
775 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
776 gtk_widget_destroy(toolbar->fgcolor_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
777 toolbar->fgcolor_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
778 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
779 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
780 if (toolbar->link_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
781 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
782 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
783 toolbar->link_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
784 } |
8784
48dd097eb475
[gaim-migrate @ 9546]
Christian Hammond <chipx86@chipx86.com>
parents:
8756
diff
changeset
|
785 |
8427 | 786 if (toolbar->sml) |
787 free(toolbar->sml); | |
8391 | 788 gtk_object_sink(GTK_OBJECT(toolbar->tooltips)); |
8317 | 789 |
8391 | 790 G_OBJECT_CLASS(parent_class)->finalize (object); |
8317 | 791 } |
792 | |
793 /* Boring GTK stuff */ | |
794 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class) | |
795 { | |
796 GtkObjectClass *object_class; | |
797 GObjectClass *gobject_class; | |
798 object_class = (GtkObjectClass*) class; | |
799 gobject_class = (GObjectClass*) class; | |
800 parent_class = gtk_type_class(GTK_TYPE_VBOX); | |
801 /* signals[URL_CLICKED] = g_signal_new(url_clicked", | |
802 G_TYPE_FROM_CLASS(gobject_class), | |
803 G_SIGNAL_RUN_FIRST, | |
804 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
805 NULL, | |
806 0, | |
807 g_cclosure_marshal_VOID__POINTER, | |
808 G_TYPE_NONE, 1, | |
809 G_TYPE_POINTER);*/ | |
810 gobject_class->finalize = gtk_imhtmltoolbar_finalize; | |
811 } | |
812 | |
813 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar) | |
814 { | |
815 GtkWidget *hbox; | |
816 GtkWidget *button; | |
817 GtkWidget *sep; | |
818 GtkSizeGroup *sg; | |
819 | |
820 toolbar->imhtml = NULL; | |
821 toolbar->font_dialog = NULL; | |
822 toolbar->fgcolor_dialog = NULL; | |
823 toolbar->bgcolor_dialog = NULL; | |
824 toolbar->link_dialog = NULL; | |
825 toolbar->smiley_dialog = NULL; | |
826 toolbar->image_dialog = NULL; | |
827 | |
828 toolbar->tooltips = gtk_tooltips_new(); | |
829 | |
830 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
831 | |
832 sep = gtk_hseparator_new(); | |
833 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
834 gtk_widget_show(sep); | |
835 | |
836 hbox = gtk_hbox_new(FALSE, 6); | |
837 gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0); | |
838 | |
839 /* Bold */ | |
840 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
841 gtk_size_group_add_widget(sg, button); | |
842 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
843 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL); | |
844 | |
845 g_signal_connect(G_OBJECT(button), "clicked", | |
846 G_CALLBACK(do_bold), toolbar); | |
847 | |
848 toolbar->bold = button; | |
849 | |
850 /* Italic */ | |
851 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
852 gtk_size_group_add_widget(sg, button); | |
853 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
854 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL); | |
855 | |
856 g_signal_connect(G_OBJECT(button), "clicked", | |
857 G_CALLBACK(do_italic), toolbar); | |
858 | |
859 toolbar->italic = button; | |
860 | |
861 /* Underline */ | |
862 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
863 gtk_size_group_add_widget(sg, button); | |
864 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
865 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL); | |
866 | |
867 g_signal_connect(G_OBJECT(button), "clicked", | |
868 G_CALLBACK(do_underline), toolbar); | |
869 | |
870 toolbar->underline = button; | |
871 | |
872 /* Sep */ | |
873 sep = gtk_vseparator_new(); | |
874 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
875 | |
876 /* Increase font size */ | |
877 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
878 gtk_size_group_add_widget(sg, button); | |
879 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
880 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
881 _("Larger font size"), NULL); | |
882 | |
883 g_signal_connect(G_OBJECT(button), "clicked", | |
884 G_CALLBACK(do_big), toolbar); | |
885 | |
886 toolbar->larger_size = button; | |
887 | |
888 /* Decrease font size */ | |
889 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
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, | |
893 _("Smaller font size"), NULL); | |
894 | |
895 g_signal_connect(G_OBJECT(button), "clicked", | |
896 G_CALLBACK(do_small), toolbar); | |
897 | |
898 toolbar->smaller_size = button; | |
899 | |
900 /* Sep */ | |
901 sep = gtk_vseparator_new(); | |
902 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
903 | |
904 /* Font Face */ | |
905 | |
906 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
907 gtk_size_group_add_widget(sg, button); | |
908 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
909 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
910 _("Font Face"), NULL); | |
911 | |
912 g_signal_connect(G_OBJECT(button), "clicked", | |
913 G_CALLBACK(toggle_font), toolbar); | |
914 | |
915 toolbar->font = button; | |
916 | |
917 /* Foreground Color */ | |
918 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
919 gtk_size_group_add_widget(sg, button); | |
920 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
921 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
922 _("Foreground font color"), NULL); | |
923 | |
924 g_signal_connect(G_OBJECT(button), "clicked", | |
925 G_CALLBACK(toggle_fg_color), toolbar); | |
926 | |
927 toolbar->fgcolor = button; | |
928 | |
929 /* Background Color */ | |
930 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
931 gtk_size_group_add_widget(sg, button); | |
932 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
933 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
934 _("Background color"), NULL); | |
935 | |
936 g_signal_connect(G_OBJECT(button), "clicked", | |
937 G_CALLBACK(toggle_bg_color), toolbar); | |
938 | |
939 toolbar->bgcolor = button; | |
940 | |
941 /* Sep */ | |
942 sep = gtk_vseparator_new(); | |
943 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
944 | |
945 /* Insert Link */ | |
946 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
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, _("Insert link"), NULL); | |
950 g_signal_connect(G_OBJECT(button), "clicked", | |
951 G_CALLBACK(insert_link_cb), toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
952 |
8317 | 953 toolbar->link = button; |
954 | |
955 /* Insert IM Image */ | |
956 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
957 gtk_size_group_add_widget(sg, button); | |
958 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
959 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert image"), NULL); | |
960 | |
961 g_signal_connect(G_OBJECT(button), "clicked", | |
962 G_CALLBACK(insert_image_cb), toolbar); | |
963 | |
964 toolbar->image = button; | |
965 | |
966 /* Insert Smiley */ | |
967 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
968 gtk_size_group_add_widget(sg, button); | |
969 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
970 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL); | |
971 | |
972 g_signal_connect(G_OBJECT(button), "clicked", | |
973 G_CALLBACK(insert_smiley_cb), toolbar); | |
974 | |
975 toolbar->smiley = button; | |
976 | |
977 | |
978 sep = gtk_hseparator_new(); | |
979 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
980 gtk_widget_show(sep); | |
8427 | 981 toolbar->sml = NULL; |
8317 | 982 gtk_widget_show_all(hbox); |
8756 | 983 |
984 /* XXX - IMIMAGE - Fix IM images then remove the following line */ | |
985 gtk_widget_hide(toolbar->image); | |
8317 | 986 } |
987 | |
988 GtkWidget *gtk_imhtmltoolbar_new() | |
989 { | |
990 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL)); | |
991 } | |
992 | |
993 GType gtk_imhtmltoolbar_get_type() | |
994 { | |
995 static GType imhtmltoolbar_type = 0; | |
996 | |
997 if (!imhtmltoolbar_type) { | |
998 static const GTypeInfo imhtmltoolbar_info = { | |
999 sizeof(GtkIMHtmlToolbarClass), | |
1000 NULL, | |
1001 NULL, | |
1002 (GClassInitFunc) gtk_imhtmltoolbar_class_init, | |
1003 NULL, | |
1004 NULL, | |
1005 sizeof (GtkIMHtmlToolbar), | |
1006 0, | |
1007 (GInstanceInitFunc) gtk_imhtmltoolbar_init | |
1008 }; | |
1009 | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
1010 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_VBOX, |
8317 | 1011 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0); |
1012 } | |
1013 | |
1014 return imhtmltoolbar_type; | |
1015 } | |
1016 | |
1017 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
1018 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml) |
8317 | 1019 { |
8788 | 1020 GtkIMHtmlButtons buttons; |
8481 | 1021 gboolean bold, italic, underline; |
1022 | |
8325
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1023 g_return_if_fail(toolbar != NULL); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1024 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar)); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1025 g_return_if_fail(imhtml != NULL); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1026 g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1027 |
8317 | 1028 toolbar->imhtml = imhtml; |
8506 | 1029 g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar); |
8420 | 1030 g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar); |
8427 | 1031 g_signal_connect(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(reset_buttons_cb), toolbar); |
8506 | 1032 g_signal_connect(G_OBJECT(imhtml), "format_function_update", G_CALLBACK(update_format_cb), toolbar); |
8516 | 1033 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", G_CALLBACK(mark_set_cb), toolbar); |
8481 | 1034 |
8788 | 1035 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)); |
1036 update_buttons_cb(imhtml, buttons, toolbar); | |
1037 | |
8481 | 1038 bold = italic = underline = FALSE; |
1039 | |
8516 | 1040 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &underline); |
8481 | 1041 |
1042 if(bold) | |
1043 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, | |
1044 toolbar); | |
1045 | |
1046 if(italic) | |
1047 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, | |
1048 toolbar); | |
1049 | |
1050 if(underline) | |
1051 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
1052 underline, toolbar); | |
8317 | 1053 } |
8427 | 1054 |
1055 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id) | |
1056 { | |
1057 if (toolbar->sml) | |
1058 g_free(toolbar->sml); | |
1059 | |
1060 toolbar->sml = g_strdup(proto_id); | |
1061 } |