Mercurial > pidgin
annotate src/gtkimhtmltoolbar.c @ 9797:62eb9fe24692
[gaim-migrate @ 10665]
"This patch adds gaim_notify_userinfo() and a notify_userinfo() UI
callback. gaim_notify_userinfo() is much like
gaim_notify_formatted() except that it always takes a
GaimConnection* as its handle and has an
additional argument, const char* who.
gaim_gtk_notify_userinfo() currently passes all the information
except the GaimConnection* and the const char* who to
gaim_gtk_notify_formatted(). This could be changed in the future
to, for example, have a standardized window title which would
note the account and/or user associated with the information.
This is needed because some UIs (Adium, for example) don't want
to present the information in a standalone window - they want to
associate the information with a particular contact / buddy and
display it with that object's other information. Previously,
gaim_notify_formatted() was not useful for this purpose as it could
not be determined what user's info it was; gaim_notify_userinfo()
makes this possible.
This patch modifies notify.c and notify.h for the new function,
modifies gtknotify.c to register the ui op and pass calls to it on the
gaim_gtk_notify_formatted, and modifies all prpls except SILC
(which I don't understand well enough to modify, but there's no
actual harm in leaving it as gaim_notify_formatted() for now) to
use gaim_notify_userinfo() and pass their gc and username when
calling the function." -- Evan Schoenberg
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 20 Aug 2004 22:05:18 +0000 |
parents | 4a15962c344a |
children | 0e3a84f18467 |
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 */ | |
9791 | 23 #include "internal.h" |
24 #include "gtkgaim.h" | |
8317 | 25 |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
26 #include "imgstore.h" |
8317 | 27 #include "notify.h" |
28 #include "request.h" | |
29 #include "stock.h" | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
30 #include "util.h" |
8317 | 31 |
9730 | 32 #include "gtkdialogs.h" |
33 #include "gtkimhtmltoolbar.h" | |
34 #include "gtkutils.h" | |
35 | |
8317 | 36 static GtkVBoxClass *parent_class = NULL; |
37 | |
38 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar) | |
39 { | |
8481 | 40 GObject *object; |
41 | |
8317 | 42 g_return_if_fail(toolbar); |
8481 | 43 |
44 /* block the format_function_toggle handler */ | |
45 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml))); | |
46 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, | |
47 NULL, toolbar); | |
8317 | 48 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml)); |
8481 | 49 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
50 NULL, toolbar); | |
51 g_object_unref(object); | |
52 | |
8317 | 53 gtk_widget_grab_focus(toolbar->imhtml); |
54 } | |
55 | |
56 static void | |
57 do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar) | |
58 { | |
8481 | 59 GObject *object; |
60 | |
8317 | 61 g_return_if_fail(toolbar); |
8481 | 62 |
63 /* block the format_function_toggle handler */ | |
64 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml))); | |
65 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, | |
66 NULL, toolbar); | |
8317 | 67 gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml)); |
8481 | 68 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
69 NULL, toolbar); | |
70 g_object_unref(object); | |
71 | |
8317 | 72 gtk_widget_grab_focus(toolbar->imhtml); |
73 } | |
74 | |
75 static void | |
76 do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar) | |
77 { | |
8481 | 78 GObject *object; |
79 | |
8317 | 80 g_return_if_fail(toolbar); |
8481 | 81 |
82 /* block the format_function_toggle handler */ | |
83 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml))); | |
84 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, | |
85 NULL, toolbar); | |
8317 | 86 gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml)); |
8481 | 87 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
88 NULL, toolbar); | |
89 g_object_unref(object); | |
90 | |
8317 | 91 gtk_widget_grab_focus(toolbar->imhtml); |
92 } | |
93 | |
94 static void | |
95 do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar) | |
96 { | |
97 g_return_if_fail(toolbar); | |
8380 | 98 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size))) |
99 gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml)); | |
8317 | 100 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE); |
101 gtk_widget_grab_focus(toolbar->imhtml); | |
102 } | |
103 | |
104 static void | |
105 do_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar) | |
106 { | |
107 g_return_if_fail(toolbar); | |
8380 | 108 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->larger_size))) |
109 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml)); | |
8317 | 110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE); |
111 gtk_widget_grab_focus(toolbar->imhtml); | |
112 } | |
113 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
114 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
115 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
116 GtkIMHtmlToolbar *toolbar) |
8317 | 117 { |
118 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->font), FALSE); | |
119 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
120 if (toolbar->font_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
121 { |
8317 | 122 gtk_widget_destroy(toolbar->font_dialog); |
123 toolbar->font_dialog = NULL; | |
124 } | |
125 } | |
126 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
127 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
128 cancel_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
129 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
130 destroy_toolbar_font(widget, NULL, toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
131 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
132 |
8317 | 133 static void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) |
134 { | |
135 /* this could be expanded to include font size, weight, etc. | |
136 but for now only works with font face */ | |
137 char *fontname; | |
138 char *space; | |
139 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), "gaim_toolbar"); | |
140 | |
141 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); | |
142 | |
143 space = strrchr(fontname, ' '); | |
144 if(space && isdigit(*(space+1))) | |
145 *space = '\0'; | |
146 | |
147 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname); | |
148 | |
149 g_free(fontname); | |
150 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
151 cancel_toolbar_font(NULL, toolbar); |
8317 | 152 } |
153 | |
154 static void | |
155 toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar) | |
156 { | |
9025 | 157 const char *fontname; |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
158 |
8317 | 159 g_return_if_fail(toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
160 |
9025 | 161 fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml)); |
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 |
9025 | 168 if(fontname) { |
169 char fonttif[128]; | |
170 g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontname); | |
171 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog), | |
172 fonttif); | |
173 } else { | |
174 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog), | |
175 DEFAULT_FONT_FACE); | |
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; | |
9025 | 234 GdkColor fgcolor; |
235 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
|
236 |
8317 | 237 if (!toolbar->fgcolor_dialog) { |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
238 |
8317 | 239 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); |
240 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->colorsel; | |
9025 | 241 if (color) { |
242 gdk_color_parse(color, &fgcolor); | |
243 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor); | |
244 } | |
245 | |
8317 | 246 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
247 |
8317 | 248 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
249 G_CALLBACK(destroy_toolbar_fgcolor), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
250 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
|
251 G_CALLBACK(do_fgcolor), colorsel); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
252 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
|
253 G_CALLBACK(cancel_toolbar_fgcolor), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
254 |
8317 | 255 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
256 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog)); |
8317 | 257 } else if (toolbar->fgcolor_dialog != NULL) { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
258 cancel_toolbar_fgcolor(color, toolbar); |
8317 | 259 } else { |
260 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
261 } | |
262 gtk_widget_grab_focus(toolbar->imhtml); | |
263 } | |
264 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
265 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
266 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
267 GtkIMHtmlToolbar *toolbar) |
8317 | 268 { |
269 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
|
270 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
271 if (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 gtk_widget_destroy(toolbar->bgcolor_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
274 toolbar->bgcolor_dialog = NULL; |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
275 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
276 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
277 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
278 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
279 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
280 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
281 destroy_toolbar_bgcolor(widget, NULL, toolbar); |
8317 | 282 } |
283 | |
284 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
285 { | |
286 GdkColor text_color; | |
287 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar"); | |
288 char *open_tag; | |
289 | |
290 open_tag = g_malloc(30); | |
291 gtk_color_selection_get_current_color(colorsel, &text_color); | |
292 g_snprintf(open_tag, 23, "#%02X%02X%02X", | |
293 text_color.red / 256, | |
294 text_color.green / 256, | |
295 text_color.blue / 256); | |
296 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag); | |
297 | |
298 g_free(open_tag); | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
299 cancel_toolbar_bgcolor(NULL, toolbar); |
8317 | 300 } |
301 | |
302 static void | |
303 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar) | |
304 { | |
305 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) { | |
306 GtkWidget *colorsel; | |
9025 | 307 GdkColor bgcolor; |
308 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
|
309 |
8317 | 310 if (!toolbar->bgcolor_dialog) { |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
311 |
8359 | 312 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color")); |
8317 | 313 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->colorsel; |
9025 | 314 if (color) { |
315 gdk_color_parse(color, &bgcolor); | |
316 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor); | |
317 } | |
318 | |
8317 | 319 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
320 |
8317 | 321 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
322 G_CALLBACK(destroy_toolbar_bgcolor), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
323 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
|
324 G_CALLBACK(do_bgcolor), colorsel); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
325 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
|
326 G_CALLBACK(cancel_toolbar_bgcolor), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
327 |
8317 | 328 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
329 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog)); |
8317 | 330 } else if (toolbar->bgcolor_dialog != NULL) { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
331 cancel_toolbar_bgcolor(color, toolbar); |
8317 | 332 } else { |
333 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
334 } | |
335 gtk_widget_grab_focus(toolbar->imhtml); | |
336 } | |
337 | |
338 static void | |
339 cancel_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields) | |
340 { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
341 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
|
342 |
8317 | 343 toolbar->link_dialog = NULL; |
344 } | |
345 | |
346 static void | |
347 close_link_dialog(GtkIMHtmlToolbar *toolbar) | |
348 { | |
349 if (toolbar->link_dialog != NULL) | |
350 { | |
351 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog); | |
352 toolbar->link_dialog = NULL; | |
353 } | |
354 } | |
355 | |
356 static void | |
357 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields) | |
358 { | |
359 const char *url, *description; | |
360 | |
361 url = gaim_request_fields_get_string(fields, "url"); | |
9041 | 362 if (GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) |
363 description = gaim_request_fields_get_string(fields, "description"); | |
364 else | |
365 description = NULL; | |
8317 | 366 |
367 if (description == NULL) | |
368 description = url; | |
369 | |
8677 | 370 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml), |
371 gtk_text_buffer_get_insert(GTK_IMHTML(toolbar->imhtml)->text_buffer), | |
372 url, description); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
373 |
8317 | 374 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE); |
375 | |
376 toolbar->link_dialog = NULL; | |
377 } | |
378 | |
379 static void | |
380 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar) | |
381 { | |
382 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) { | |
383 GaimRequestFields *fields; | |
384 GaimRequestFieldGroup *group; | |
385 GaimRequestField *field; | |
9599 | 386 GtkTextIter start, end; |
9041 | 387 char *msg; |
9599 | 388 char *desc = NULL; |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
389 |
8317 | 390 fields = gaim_request_fields_new(); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
391 |
8317 | 392 group = gaim_request_field_group_new(NULL); |
393 gaim_request_fields_add_group(fields, group); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
394 |
8317 | 395 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE); |
396 gaim_request_field_set_required(field, TRUE); | |
397 gaim_request_field_group_add_field(group, field); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
398 |
9041 | 399 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) { |
9599 | 400 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, &start, &end)) { |
401 desc = gtk_imhtml_get_text(GTK_IMHTML(toolbar->imhtml), &start, &end); | |
402 } | |
9041 | 403 field = gaim_request_field_string_new("description", _("_Description"), |
9599 | 404 desc, FALSE); |
9041 | 405 gaim_request_field_group_add_field(group, field); |
406 msg = g_strdup(_("Please enter the URL and description of the " | |
407 "link that you want to insert. The description " | |
408 "is optional.")); | |
409 } else { | |
410 msg = g_strdup(_("Please enter the URL of the " | |
411 "link that you want to insert.")); | |
412 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
413 |
8317 | 414 toolbar->link_dialog = |
415 gaim_request_fields(toolbar, _("Insert Link"), | |
416 NULL, | |
9041 | 417 msg, |
8317 | 418 fields, |
419 _("_Insert"), G_CALLBACK(do_insert_link_cb), | |
420 _("Cancel"), G_CALLBACK(cancel_link_cb), | |
421 toolbar); | |
9041 | 422 g_free(msg); |
9599 | 423 g_free(desc); |
8322
ffb601c6b833
[gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents:
8321
diff
changeset
|
424 } else { |
8317 | 425 close_link_dialog(toolbar); |
426 } | |
427 gtk_widget_grab_focus(toolbar->imhtml); | |
428 } | |
429 | |
430 | |
431 static void | |
9522 | 432 do_insert_image_cb(GtkWidget *widget, int response, GtkIMHtmlToolbar *toolbar) |
8317 | 433 { |
9522 | 434 gchar *filename, *name, *buf; |
435 char *filedata; | |
8317 | 436 size_t size; |
437 GError *error = NULL; | |
438 int id; | |
8962 | 439 GtkTextIter iter; |
440 GtkTextMark *ins; | |
8317 | 441 |
9522 | 442 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
443 if (response != GTK_RESPONSE_ACCEPT) { | |
444 #else /* FILECHOOSER */ | |
445 if (response != GTK_RESPONSE_OK) { | |
446 #endif /* FILECHOOSER */ | |
8317 | 447 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); |
448 return; | |
449 } | |
450 | |
9522 | 451 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
452 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); | |
453 #else /* FILECHOOSER */ | |
454 filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget))); | |
455 #endif /* FILECHOOSER */ | |
8317 | 456 |
9522 | 457 if (filename == NULL) { |
8317 | 458 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); |
459 return; | |
460 } | |
461 | |
9522 | 462 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
463 if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(widget))) { | |
464 g_free(filename); | |
465 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
466 return; | |
467 } | |
468 #endif /* FILECHOOSER */ | |
469 | |
470 /* The following triggers a callback that closes the widget */ | |
8317 | 471 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); |
472 | |
9522 | 473 if (!g_file_get_contents(filename, &filedata, &size, &error)) { |
8317 | 474 gaim_notify_error(NULL, NULL, error->message, NULL); |
475 | |
476 g_error_free(error); | |
9522 | 477 g_free(filename); |
8317 | 478 |
479 return; | |
480 } | |
481 | |
9522 | 482 name = strrchr(filename, G_DIR_SEPARATOR) + 1; |
8317 | 483 |
9522 | 484 id = gaim_imgstore_add(filedata, size, name); |
8317 | 485 g_free(filedata); |
486 | |
9522 | 487 if (id == 0) { |
488 buf = g_strdup_printf(_("Failed to store image: %s\n"), filename); | |
8317 | 489 gaim_notify_error(NULL, NULL, buf, NULL); |
490 | |
491 g_free(buf); | |
9522 | 492 g_free(filename); |
8317 | 493 |
494 return; | |
495 } | |
496 | |
9522 | 497 g_free(filename); |
498 | |
8962 | 499 ins = gtk_text_buffer_get_insert(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml))); |
500 gtk_text_buffer_get_iter_at_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)), | |
9522 | 501 &iter, ins); |
8962 | 502 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(toolbar->imhtml), id, &iter); |
503 gaim_imgstore_unref(id); | |
8317 | 504 } |
505 | |
506 | |
507 static void | |
508 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar) | |
509 { | |
510 GtkWidget *window; | |
511 | |
512 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) { | |
9522 | 513 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
514 window = gtk_file_chooser_dialog_new(_("Insert Image"), | |
515 NULL, | |
516 GTK_FILE_CHOOSER_ACTION_OPEN, | |
517 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
518 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | |
519 NULL); | |
520 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_ACCEPT); | |
521 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(window)), | |
522 "response", G_CALLBACK(do_insert_image_cb), toolbar); | |
523 #else /* FILECHOOSER */ | |
8317 | 524 window = gtk_file_selection_new(_("Insert Image")); |
525 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK); | |
526 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)), | |
527 "response", G_CALLBACK(do_insert_image_cb), toolbar); | |
9522 | 528 #endif /* FILECHOOSER */ |
8317 | 529 |
530 gtk_widget_show(window); | |
531 toolbar->image_dialog = window; | |
532 } else { | |
533 gtk_widget_destroy(toolbar->image_dialog); | |
534 toolbar->image_dialog = NULL; | |
535 } | |
9522 | 536 |
8317 | 537 gtk_widget_grab_focus(toolbar->imhtml); |
538 } | |
539 | |
540 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
541 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
542 close_smiley_dialog(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
543 GtkIMHtmlToolbar *toolbar) |
8317 | 544 { |
545 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
|
546 |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
547 if (toolbar->smiley_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
548 { |
8317 | 549 gtk_widget_destroy(toolbar->smiley_dialog); |
550 toolbar->smiley_dialog = NULL; | |
551 } | |
552 } | |
553 | |
554 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
555 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
556 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
8317 | 557 { |
9027 | 558 char *smiley_text, *escaped_smiley; |
559 | |
560 smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | |
561 escaped_smiley = gaim_escape_html(smiley_text); | |
8317 | 562 |
8456 | 563 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml), |
564 GTK_IMHTML(toolbar->imhtml)->protocol_name, | |
9027 | 565 escaped_smiley); |
8317 | 566 |
9027 | 567 g_free(escaped_smiley); |
8320
5c6c8d48946f
[gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
568 close_smiley_dialog(NULL, NULL, toolbar); |
8317 | 569 } |
570 | |
571 | |
572 static void add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face) | |
573 { | |
574 GtkWidget *image; | |
575 GtkWidget *button; | |
576 | |
577 image = gtk_image_new_from_file(filename); | |
578 button = gtk_button_new(); | |
579 gtk_container_add(GTK_CONTAINER(button), image); | |
580 g_object_set_data(G_OBJECT(button), "smiley_text", face); | |
581 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar); | |
582 | |
583 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL); | |
584 | |
585 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1); | |
586 | |
587 /* these look really weird with borders */ | |
588 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
589 | |
590 gtk_widget_show(button); | |
591 } | |
592 | |
593 | |
594 static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) { | |
595 while(list) { | |
596 GtkIMHtmlSmiley *cur = list->data; | |
597 if(!strcmp(cur->file, smiley->file)) | |
598 return FALSE; | |
599 list = list->next; | |
600 } | |
601 return TRUE; | |
602 } | |
603 | |
604 | |
605 static void | |
606 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar) | |
607 { | |
608 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
609 |
8317 | 610 GtkWidget *dialog; |
611 GtkWidget *smiley_table = NULL; | |
612 GSList *smileys, *unique_smileys = NULL; | |
613 int width; | |
614 int row = 0, col = 0; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
615 |
8317 | 616 if (toolbar->smiley_dialog) { |
617 gtk_widget_grab_focus(toolbar->imhtml); | |
618 return; | |
619 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
620 |
8427 | 621 if (toolbar->sml) |
622 smileys = get_proto_smileys(toolbar->sml); | |
8892 | 623 else |
624 smileys = get_proto_smileys(GAIM_PROTO_DEFAULT); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
625 |
8317 | 626 while(smileys) { |
627 GtkIMHtmlSmiley *smiley = smileys->data; | |
628 if(!smiley->hidden) { | |
629 if(smiley_is_unique(unique_smileys, smiley)) | |
630 unique_smileys = g_slist_append(unique_smileys, smiley); | |
631 } | |
632 smileys = smileys->next; | |
633 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
634 |
8892 | 635 GAIM_DIALOG(dialog); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
636 |
8317 | 637 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
638 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); | |
639 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
|
640 |
8892 | 641 if(g_slist_length(unique_smileys)) { |
642 | |
643 width = floor(sqrt(g_slist_length(unique_smileys))); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
644 |
8892 | 645 smiley_table = gtk_table_new(width, width, TRUE); |
646 | |
647 /* pack buttons */ | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
648 |
8892 | 649 while(unique_smileys) { |
650 GtkIMHtmlSmiley *smiley = unique_smileys->data; | |
651 if(!smiley->hidden) { | |
652 add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile); | |
653 if(++col >= width) { | |
654 col = 0; | |
655 row++; | |
656 } | |
8317 | 657 } |
8892 | 658 unique_smileys = unique_smileys->next; |
8317 | 659 } |
8892 | 660 } |
661 else { | |
662 smiley_table = gtk_label_new(_("This theme has no available smileys.")); | |
8317 | 663 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
664 |
8317 | 665 gtk_container_add(GTK_CONTAINER(dialog), smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
666 |
8317 | 667 gtk_widget_show(smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
668 |
8317 | 669 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
670 |
8317 | 671 /* connect signals */ |
672 g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog"); | |
673 g_signal_connect(G_OBJECT(dialog), "delete_event", | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
674 G_CALLBACK(close_smiley_dialog), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
675 |
8317 | 676 /* show everything */ |
677 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!")); | |
678 gtk_widget_show_all(dialog); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
679 |
8317 | 680 toolbar->smiley_dialog = dialog; |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
681 |
8317 | 682 } else if (toolbar->smiley_dialog) { |
8320
5c6c8d48946f
[gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
683 close_smiley_dialog(smiley, NULL, toolbar); |
8317 | 684 } |
685 gtk_widget_grab_focus(toolbar->imhtml); | |
686 } | |
687 | |
8420 | 688 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) |
689 { | |
690 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bold), buttons & GTK_IMHTML_BOLD); | |
691 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->italic), buttons & GTK_IMHTML_ITALIC); | |
692 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->underline), buttons & GTK_IMHTML_UNDERLINE); | |
693 | |
694 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->larger_size), buttons & GTK_IMHTML_GROW); | |
695 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smaller_size), buttons & GTK_IMHTML_SHRINK); | |
696 | |
697 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->font), buttons & GTK_IMHTML_FACE); | |
698 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->fgcolor), buttons & GTK_IMHTML_FORECOLOR); | |
699 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bgcolor), buttons & GTK_IMHTML_BACKCOLOR); | |
700 | |
701 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->image), buttons & GTK_IMHTML_IMAGE); | |
702 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->link), buttons & GTK_IMHTML_LINK); | |
703 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smiley), buttons & GTK_IMHTML_SMILEY); | |
8481 | 704 } |
8420 | 705 |
8481 | 706 /* we call this when we want to _set_active the toggle button, it'll |
707 * block the callback thats connected to the button so we don't have to | |
708 * do the double toggling hack | |
709 */ | |
710 static void toggle_button_set_active_block(GtkToggleButton *button, | |
711 gboolean is_active, | |
712 GtkIMHtmlToolbar *toolbar) | |
713 { | |
714 GObject *object; | |
715 g_return_if_fail(toolbar); | |
716 | |
717 object = g_object_ref(button); | |
718 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, | |
719 0, 0, NULL, NULL, toolbar); | |
720 gtk_toggle_button_set_active(button, is_active); | |
721 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, | |
722 0, 0, NULL, NULL, toolbar); | |
723 g_object_unref(object); | |
8420 | 724 } |
725 | |
726 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar) | |
727 { | |
8481 | 728 if (buttons & GTK_IMHTML_BOLD) |
729 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), | |
730 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)), | |
731 toolbar); | |
8420 | 732 |
8481 | 733 if (buttons & GTK_IMHTML_ITALIC) |
734 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), | |
735 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)), | |
736 toolbar); | |
8420 | 737 |
8481 | 738 if (buttons & GTK_IMHTML_UNDERLINE) |
739 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
740 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)), | |
741 toolbar); | |
8420 | 742 } |
743 | |
8427 | 744 static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) |
745 { | |
8481 | 746 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold))) |
747 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), FALSE, | |
748 toolbar); | |
749 | |
750 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic))) | |
751 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), | |
752 FALSE, toolbar); | |
753 | |
754 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline))) | |
755 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
756 FALSE, toolbar); | |
757 } | |
8516 | 758 |
759 static void update_buttons(GtkIMHtmlToolbar *toolbar) { | |
8506 | 760 gboolean bold, italic, underline; |
761 | |
762 bold = italic = underline = FALSE; | |
8516 | 763 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml), |
764 &bold, &italic, &underline); | |
8506 | 765 |
766 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)) != bold) | |
767 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, | |
768 toolbar); | |
8516 | 769 |
8506 | 770 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)) != italic) |
771 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, | |
772 toolbar); | |
8516 | 773 |
8506 | 774 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)) != underline) |
775 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
8677 | 776 underline, toolbar); |
8506 | 777 } |
8481 | 778 |
8516 | 779 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) { |
780 update_buttons(toolbar); | |
781 } | |
8481 | 782 |
8516 | 783 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location, |
784 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar) | |
785 { | |
786 if(mark != gtk_text_buffer_get_insert(buffer)) | |
787 return; | |
788 | |
789 update_buttons(toolbar); | |
8427 | 790 } |
791 | |
8317 | 792 enum { |
793 LAST_SIGNAL | |
794 }; | |
795 //static guint signals [LAST_SIGNAL] = { 0 }; | |
796 | |
797 static void | |
798 gtk_imhtmltoolbar_finalize (GObject *object) | |
799 { | |
8391 | 800 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object); |
8317 | 801 |
8685
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
802 if (toolbar->image_dialog != NULL) |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
803 { |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
804 gtk_widget_destroy(toolbar->image_dialog); |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
805 toolbar->image_dialog = NULL; |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
806 } |
2ac2f4cf1de5
[gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents:
8677
diff
changeset
|
807 |
8785
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
808 if (toolbar->font_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
809 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
810 gtk_widget_destroy(toolbar->font_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
811 toolbar->font_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
812 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
813 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
814 if (toolbar->smiley_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
815 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
816 gtk_widget_destroy(toolbar->smiley_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
817 toolbar->smiley_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
818 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
819 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
820 if (toolbar->bgcolor_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
821 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
822 gtk_widget_destroy(toolbar->bgcolor_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
823 toolbar->bgcolor_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
824 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
825 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
826 if (toolbar->fgcolor_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
827 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
828 gtk_widget_destroy(toolbar->fgcolor_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
829 toolbar->fgcolor_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
830 } |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
831 |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
832 if (toolbar->link_dialog != NULL) |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
833 { |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
834 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog); |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
835 toolbar->link_dialog = NULL; |
a871dec1c9d6
[gaim-migrate @ 9547]
Christian Hammond <chipx86@chipx86.com>
parents:
8784
diff
changeset
|
836 } |
8784
48dd097eb475
[gaim-migrate @ 9546]
Christian Hammond <chipx86@chipx86.com>
parents:
8756
diff
changeset
|
837 |
8427 | 838 if (toolbar->sml) |
839 free(toolbar->sml); | |
8391 | 840 gtk_object_sink(GTK_OBJECT(toolbar->tooltips)); |
8317 | 841 |
8391 | 842 G_OBJECT_CLASS(parent_class)->finalize (object); |
8317 | 843 } |
844 | |
845 /* Boring GTK stuff */ | |
846 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class) | |
847 { | |
848 GtkObjectClass *object_class; | |
849 GObjectClass *gobject_class; | |
850 object_class = (GtkObjectClass*) class; | |
851 gobject_class = (GObjectClass*) class; | |
852 parent_class = gtk_type_class(GTK_TYPE_VBOX); | |
853 /* signals[URL_CLICKED] = g_signal_new(url_clicked", | |
854 G_TYPE_FROM_CLASS(gobject_class), | |
855 G_SIGNAL_RUN_FIRST, | |
856 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
857 NULL, | |
858 0, | |
859 g_cclosure_marshal_VOID__POINTER, | |
860 G_TYPE_NONE, 1, | |
861 G_TYPE_POINTER);*/ | |
862 gobject_class->finalize = gtk_imhtmltoolbar_finalize; | |
863 } | |
864 | |
865 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar) | |
866 { | |
867 GtkWidget *hbox; | |
868 GtkWidget *button; | |
869 GtkWidget *sep; | |
870 GtkSizeGroup *sg; | |
871 | |
872 toolbar->imhtml = NULL; | |
873 toolbar->font_dialog = NULL; | |
874 toolbar->fgcolor_dialog = NULL; | |
875 toolbar->bgcolor_dialog = NULL; | |
876 toolbar->link_dialog = NULL; | |
877 toolbar->smiley_dialog = NULL; | |
878 toolbar->image_dialog = NULL; | |
879 | |
880 toolbar->tooltips = gtk_tooltips_new(); | |
881 | |
882 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
883 | |
884 sep = gtk_hseparator_new(); | |
885 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
886 gtk_widget_show(sep); | |
887 | |
888 hbox = gtk_hbox_new(FALSE, 6); | |
889 gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0); | |
890 | |
891 /* Bold */ | |
892 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
893 gtk_size_group_add_widget(sg, button); | |
894 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
895 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL); | |
896 | |
897 g_signal_connect(G_OBJECT(button), "clicked", | |
898 G_CALLBACK(do_bold), toolbar); | |
899 | |
900 toolbar->bold = button; | |
901 | |
902 /* Italic */ | |
903 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
904 gtk_size_group_add_widget(sg, button); | |
905 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
906 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL); | |
907 | |
908 g_signal_connect(G_OBJECT(button), "clicked", | |
909 G_CALLBACK(do_italic), toolbar); | |
910 | |
911 toolbar->italic = button; | |
912 | |
913 /* Underline */ | |
914 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
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, _("Underline"), NULL); | |
918 | |
919 g_signal_connect(G_OBJECT(button), "clicked", | |
920 G_CALLBACK(do_underline), toolbar); | |
921 | |
922 toolbar->underline = button; | |
923 | |
924 /* Sep */ | |
925 sep = gtk_vseparator_new(); | |
926 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
927 | |
928 /* Increase font size */ | |
929 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
930 gtk_size_group_add_widget(sg, button); | |
931 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
932 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
933 _("Larger font size"), NULL); | |
934 | |
935 g_signal_connect(G_OBJECT(button), "clicked", | |
936 G_CALLBACK(do_big), toolbar); | |
937 | |
938 toolbar->larger_size = button; | |
939 | |
940 /* Decrease font size */ | |
941 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
942 gtk_size_group_add_widget(sg, button); | |
943 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
944 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
945 _("Smaller font size"), NULL); | |
946 | |
947 g_signal_connect(G_OBJECT(button), "clicked", | |
948 G_CALLBACK(do_small), toolbar); | |
949 | |
950 toolbar->smaller_size = button; | |
951 | |
952 /* Sep */ | |
953 sep = gtk_vseparator_new(); | |
954 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
955 | |
956 /* Font Face */ | |
957 | |
958 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
959 gtk_size_group_add_widget(sg, button); | |
960 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
961 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
962 _("Font Face"), NULL); | |
963 | |
964 g_signal_connect(G_OBJECT(button), "clicked", | |
965 G_CALLBACK(toggle_font), toolbar); | |
966 | |
967 toolbar->font = button; | |
968 | |
969 /* Foreground Color */ | |
970 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
971 gtk_size_group_add_widget(sg, button); | |
972 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
973 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
974 _("Foreground font color"), NULL); | |
975 | |
976 g_signal_connect(G_OBJECT(button), "clicked", | |
977 G_CALLBACK(toggle_fg_color), toolbar); | |
978 | |
979 toolbar->fgcolor = button; | |
980 | |
981 /* Background Color */ | |
982 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
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, | |
986 _("Background color"), NULL); | |
987 | |
988 g_signal_connect(G_OBJECT(button), "clicked", | |
989 G_CALLBACK(toggle_bg_color), toolbar); | |
990 | |
991 toolbar->bgcolor = button; | |
992 | |
993 /* Sep */ | |
994 sep = gtk_vseparator_new(); | |
995 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
996 | |
997 /* Insert Link */ | |
998 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
999 gtk_size_group_add_widget(sg, button); | |
1000 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
1001 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL); | |
1002 g_signal_connect(G_OBJECT(button), "clicked", | |
1003 G_CALLBACK(insert_link_cb), toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
1004 |
8317 | 1005 toolbar->link = button; |
1006 | |
1007 /* Insert IM Image */ | |
1008 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
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, _("Insert image"), NULL); | |
1012 | |
1013 g_signal_connect(G_OBJECT(button), "clicked", | |
1014 G_CALLBACK(insert_image_cb), toolbar); | |
1015 | |
1016 toolbar->image = button; | |
1017 | |
1018 /* Insert Smiley */ | |
1019 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
1020 gtk_size_group_add_widget(sg, button); | |
1021 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
1022 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL); | |
1023 | |
1024 g_signal_connect(G_OBJECT(button), "clicked", | |
1025 G_CALLBACK(insert_smiley_cb), toolbar); | |
1026 | |
1027 toolbar->smiley = button; | |
1028 | |
1029 | |
1030 sep = gtk_hseparator_new(); | |
1031 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
1032 gtk_widget_show(sep); | |
8427 | 1033 toolbar->sml = NULL; |
8317 | 1034 gtk_widget_show_all(hbox); |
1035 } | |
1036 | |
1037 GtkWidget *gtk_imhtmltoolbar_new() | |
1038 { | |
1039 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL)); | |
1040 } | |
1041 | |
1042 GType gtk_imhtmltoolbar_get_type() | |
1043 { | |
1044 static GType imhtmltoolbar_type = 0; | |
1045 | |
1046 if (!imhtmltoolbar_type) { | |
1047 static const GTypeInfo imhtmltoolbar_info = { | |
1048 sizeof(GtkIMHtmlToolbarClass), | |
1049 NULL, | |
1050 NULL, | |
1051 (GClassInitFunc) gtk_imhtmltoolbar_class_init, | |
1052 NULL, | |
1053 NULL, | |
1054 sizeof (GtkIMHtmlToolbar), | |
1055 0, | |
1056 (GInstanceInitFunc) gtk_imhtmltoolbar_init | |
1057 }; | |
1058 | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
1059 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_VBOX, |
8317 | 1060 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0); |
1061 } | |
1062 | |
1063 return imhtmltoolbar_type; | |
1064 } | |
1065 | |
1066 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
1067 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml) |
8317 | 1068 { |
8788 | 1069 GtkIMHtmlButtons buttons; |
8481 | 1070 gboolean bold, italic, underline; |
1071 | |
8325
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1072 g_return_if_fail(toolbar != NULL); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1073 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar)); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1074 g_return_if_fail(imhtml != NULL); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1075 g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
1076 |
8317 | 1077 toolbar->imhtml = imhtml; |
8506 | 1078 g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar); |
8420 | 1079 g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar); |
8427 | 1080 g_signal_connect(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(reset_buttons_cb), toolbar); |
8506 | 1081 g_signal_connect(G_OBJECT(imhtml), "format_function_update", G_CALLBACK(update_format_cb), toolbar); |
8516 | 1082 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", G_CALLBACK(mark_set_cb), toolbar); |
8481 | 1083 |
8788 | 1084 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)); |
8807 | 1085 update_buttons_cb(GTK_IMHTML(imhtml), buttons, toolbar); |
8788 | 1086 |
8481 | 1087 bold = italic = underline = FALSE; |
1088 | |
8516 | 1089 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &underline); |
8481 | 1090 |
1091 if(bold) | |
1092 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold, | |
1093 toolbar); | |
1094 | |
1095 if(italic) | |
1096 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic, | |
1097 toolbar); | |
1098 | |
1099 if(underline) | |
1100 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline), | |
1101 underline, toolbar); | |
8317 | 1102 } |
8427 | 1103 |
1104 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id) | |
1105 { | |
1106 if (toolbar->sml) | |
1107 g_free(toolbar->sml); | |
1108 | |
1109 toolbar->sml = g_strdup(proto_id); | |
1110 } |