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