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