Mercurial > pidgin.yaz
annotate src/gtkimhtmltoolbar.c @ 8329:9dd7c75ed433
[gaim-migrate @ 9053]
Handle the display of the formatting toolbar correctly. Only the first tab
was getting a toolbar. Now it should work for all conversations.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 24 Feb 2004 04:27:58 +0000 |
parents | 415283e39bce |
children | 05c174138e94 |
rev | line source |
---|---|
8317 | 1 /* |
2 * GtkIMHtmlToolbar | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
23 #include "gtkinternal.h" |
8317 | 24 |
25 #include "gtkimhtmltoolbar.h" | |
26 #include "gtkutils.h" | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
27 |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
28 #include "imgstore.h" |
8317 | 29 #include "notify.h" |
30 #include "request.h" | |
31 #include "stock.h" | |
32 #include "ui.h" | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
33 #include "util.h" |
8317 | 34 |
35 static GtkVBoxClass *parent_class = NULL; | |
36 | |
37 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar) | |
38 { | |
39 g_return_if_fail(toolbar); | |
40 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml)); | |
41 gtk_widget_grab_focus(toolbar->imhtml); | |
42 } | |
43 | |
44 static void | |
45 do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar) | |
46 { | |
47 g_return_if_fail(toolbar); | |
48 gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml)); | |
49 gtk_widget_grab_focus(toolbar->imhtml); | |
50 } | |
51 | |
52 static void | |
53 do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar) | |
54 { | |
55 g_return_if_fail(toolbar); | |
56 gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml)); | |
57 gtk_widget_grab_focus(toolbar->imhtml); | |
58 } | |
59 | |
60 static void | |
61 do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar) | |
62 { | |
63 g_return_if_fail(toolbar); | |
64 gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml)); | |
65 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE); | |
66 gtk_widget_grab_focus(toolbar->imhtml); | |
67 } | |
68 | |
69 static void | |
70 do_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar) | |
71 { | |
72 g_return_if_fail(toolbar); | |
73 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml)); | |
74 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE); | |
75 gtk_widget_grab_focus(toolbar->imhtml); | |
76 } | |
77 | |
78 | |
79 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
80 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
81 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
82 GtkIMHtmlToolbar *toolbar) |
8317 | 83 { |
84 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->font), FALSE); | |
85 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
86 if (toolbar->font_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
87 { |
8317 | 88 gtk_widget_destroy(toolbar->font_dialog); |
89 toolbar->font_dialog = NULL; | |
90 } | |
91 } | |
92 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
93 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
94 cancel_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
95 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
96 destroy_toolbar_font(widget, NULL, toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
97 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
98 |
8317 | 99 static void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) |
100 { | |
101 /* this could be expanded to include font size, weight, etc. | |
102 but for now only works with font face */ | |
103 char *fontname; | |
104 char *space; | |
105 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), "gaim_toolbar"); | |
106 | |
107 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); | |
108 | |
109 space = strrchr(fontname, ' '); | |
110 if(space && isdigit(*(space+1))) | |
111 *space = '\0'; | |
112 | |
113 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname); | |
114 | |
115 g_free(fontname); | |
116 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
117 cancel_toolbar_font(NULL, toolbar); |
8317 | 118 } |
119 | |
120 static void | |
121 toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar) | |
122 { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
123 #if 0 |
8317 | 124 char fonttif[128]; |
125 const char *fontface; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
126 #endif |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
127 |
8317 | 128 g_return_if_fail(toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
129 |
8317 | 130 if (!toolbar->font_dialog) { |
131 toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font")); | |
132 | |
133 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
|
134 |
8317 | 135 /* if (gtkconv->fontface[0]) { |
136 g_snprintf(fonttif, sizeof(fonttif), "%s 12", gtkconv->fontface); | |
137 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font), | |
138 fonttif); | |
139 } else { | |
140 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(gtkconv->dialogs.font), | |
141 DEFAULT_FONT_FACE); | |
142 } | |
143 */ | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
144 |
8317 | 145 g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
146 G_CALLBACK(destroy_toolbar_font), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
147 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
|
148 G_CALLBACK(apply_font), toolbar->font_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
149 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
|
150 G_CALLBACK(cancel_toolbar_font), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
151 |
8317 | 152 gtk_window_present(GTK_WINDOW(toolbar->font_dialog)); |
153 } else { | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
154 cancel_toolbar_font(NULL, toolbar); |
8317 | 155 } |
156 gtk_widget_grab_focus(toolbar->imhtml); | |
157 } | |
158 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
159 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
160 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
161 GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
162 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
163 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->fgcolor), FALSE); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
164 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
165 if (toolbar->fgcolor_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
166 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
167 gtk_widget_destroy(toolbar->fgcolor_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
168 toolbar->fgcolor_dialog = NULL; |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
169 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
170 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
171 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
172 static void cancel_toolbar_fgcolor(GtkWidget *widget, |
8321
eb269b81fff8
[gaim-migrate @ 9045]
Christian Hammond <chipx86@chipx86.com>
parents:
8320
diff
changeset
|
173 GtkIMHtmlToolbar *toolbar) |
8317 | 174 { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
175 destroy_toolbar_fgcolor(widget, NULL, toolbar); |
8317 | 176 } |
177 | |
178 static void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
179 { | |
180 GdkColor text_color; | |
181 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar"); | |
182 char *open_tag; | |
183 | |
184 open_tag = g_malloc(30); | |
185 gtk_color_selection_get_current_color(colorsel, &text_color); | |
186 g_snprintf(open_tag, 23, "#%02X%02X%02X", | |
187 text_color.red / 256, | |
188 text_color.green / 256, | |
189 text_color.blue / 256); | |
190 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag); | |
191 | |
192 g_free(open_tag); | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
193 cancel_toolbar_fgcolor(NULL, toolbar); |
8317 | 194 } |
195 | |
196 static void | |
197 toggle_fg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar) | |
198 { | |
199 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) { | |
200 GtkWidget *colorsel; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
201 /* GdkColor fgcolor; */ |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
202 |
8317 | 203 /*gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
204 &fgcolor);*/ | |
205 if (!toolbar->fgcolor_dialog) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
206 |
8317 | 207 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); |
208 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->colorsel; | |
209 //gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor); | |
210 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
211 |
8317 | 212 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
213 G_CALLBACK(destroy_toolbar_fgcolor), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
214 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
|
215 G_CALLBACK(do_fgcolor), colorsel); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
216 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
|
217 G_CALLBACK(cancel_toolbar_fgcolor), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
218 |
8317 | 219 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
220 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog)); |
8317 | 221 } else if (toolbar->fgcolor_dialog != NULL) { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
222 cancel_toolbar_fgcolor(color, toolbar); |
8317 | 223 } else { |
224 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
225 } | |
226 gtk_widget_grab_focus(toolbar->imhtml); | |
227 } | |
228 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
229 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
230 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
231 GtkIMHtmlToolbar *toolbar) |
8317 | 232 { |
233 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
|
234 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
235 if (toolbar->bgcolor_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
236 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
237 gtk_widget_destroy(toolbar->bgcolor_dialog); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
238 toolbar->bgcolor_dialog = NULL; |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
239 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
240 } |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
241 |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
242 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
243 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
244 { |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
245 destroy_toolbar_bgcolor(widget, NULL, toolbar); |
8317 | 246 } |
247 | |
248 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | |
249 { | |
250 GdkColor text_color; | |
251 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar"); | |
252 char *open_tag; | |
253 | |
254 open_tag = g_malloc(30); | |
255 gtk_color_selection_get_current_color(colorsel, &text_color); | |
256 g_snprintf(open_tag, 23, "#%02X%02X%02X", | |
257 text_color.red / 256, | |
258 text_color.green / 256, | |
259 text_color.blue / 256); | |
260 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag); | |
261 | |
262 g_free(open_tag); | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
263 cancel_toolbar_bgcolor(NULL, toolbar); |
8317 | 264 } |
265 | |
266 static void | |
267 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar) | |
268 { | |
269 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) { | |
270 GtkWidget *colorsel; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
271 /* GdkColor bgcolor; */ |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
272 |
8317 | 273 /*gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
274 &bgcolor);*/ | |
275 if (!toolbar->bgcolor_dialog) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
276 |
8317 | 277 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color")); |
278 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->colorsel; | |
279 //gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor); | |
280 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
281 |
8317 | 282 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event", |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
283 G_CALLBACK(destroy_toolbar_bgcolor), toolbar); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
284 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
|
285 G_CALLBACK(do_bgcolor), colorsel); |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
286 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
|
287 G_CALLBACK(cancel_toolbar_bgcolor), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
288 |
8317 | 289 } |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
290 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog)); |
8317 | 291 } else if (toolbar->bgcolor_dialog != NULL) { |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
292 cancel_toolbar_bgcolor(color, toolbar); |
8317 | 293 } else { |
294 //gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
295 } | |
296 gtk_widget_grab_focus(toolbar->imhtml); | |
297 } | |
298 | |
299 static void | |
300 cancel_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields) | |
301 { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
302 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
|
303 |
8317 | 304 toolbar->link_dialog = NULL; |
305 } | |
306 | |
307 static void | |
308 close_link_dialog(GtkIMHtmlToolbar *toolbar) | |
309 { | |
310 if (toolbar->link_dialog != NULL) | |
311 { | |
312 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog); | |
313 toolbar->link_dialog = NULL; | |
314 } | |
315 } | |
316 | |
317 static void | |
318 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields) | |
319 { | |
320 const char *url, *description; | |
321 | |
322 url = gaim_request_fields_get_string(fields, "url"); | |
323 description = gaim_request_fields_get_string(fields, "description"); | |
324 | |
325 if (description == NULL) | |
326 description = url; | |
327 | |
328 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml), url, description); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
329 |
8317 | 330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE); |
331 | |
332 toolbar->link_dialog = NULL; | |
333 } | |
334 | |
335 static void | |
336 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar) | |
337 { | |
338 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) { | |
339 GaimRequestFields *fields; | |
340 GaimRequestFieldGroup *group; | |
341 GaimRequestField *field; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
342 |
8317 | 343 fields = gaim_request_fields_new(); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
344 |
8317 | 345 group = gaim_request_field_group_new(NULL); |
346 gaim_request_fields_add_group(fields, group); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
347 |
8317 | 348 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE); |
349 gaim_request_field_set_required(field, TRUE); | |
350 gaim_request_field_group_add_field(group, field); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
351 |
8317 | 352 field = gaim_request_field_string_new("description", _("_Description"), |
353 NULL, FALSE); | |
354 gaim_request_field_group_add_field(group, field); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
355 |
8317 | 356 toolbar->link_dialog = |
357 gaim_request_fields(toolbar, _("Insert Link"), | |
358 NULL, | |
359 _("Please enter the URL and description of the " | |
360 "link that you want to insert. The description " | |
361 "is optional."), | |
362 fields, | |
363 _("_Insert"), G_CALLBACK(do_insert_link_cb), | |
364 _("Cancel"), G_CALLBACK(cancel_link_cb), | |
365 toolbar); | |
8322
ffb601c6b833
[gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents:
8321
diff
changeset
|
366 } else { |
8317 | 367 close_link_dialog(toolbar); |
368 } | |
369 gtk_widget_grab_focus(toolbar->imhtml); | |
370 } | |
371 | |
372 | |
373 static void | |
374 do_insert_image_cb(GtkWidget *widget, int resp, GtkIMHtmlToolbar *toolbar) | |
375 { | |
376 char *name, *filename; | |
377 char *buf, *filedata; | |
378 size_t size; | |
379 GError *error = NULL; | |
380 int id; | |
381 | |
382 if (resp != GTK_RESPONSE_OK) { | |
383 //set_toggle(toolbar->image, FALSE); | |
384 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
385 return; | |
386 } | |
387 | |
388 name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget))); | |
389 | |
390 if (!name) { | |
391 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
392 return; | |
393 } | |
394 | |
395 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(widget))) { | |
396 g_free(name); | |
397 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
398 return; | |
399 } | |
400 | |
401 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE); | |
402 | |
403 if (!g_file_get_contents(name, &filedata, &size, &error)) { | |
404 gaim_notify_error(NULL, NULL, error->message, NULL); | |
405 | |
406 g_error_free(error); | |
407 g_free(name); | |
408 | |
409 return; | |
410 } | |
411 | |
412 filename = name; | |
413 while (strchr(filename, '/')) | |
414 filename = strchr(filename, '/') + 1; | |
415 | |
416 id = gaim_imgstore_add(filedata, size, filename); | |
417 g_free(filedata); | |
418 | |
419 if (!id) { | |
420 buf = g_strdup_printf(_("Failed to store image: %s\n"), name); | |
421 gaim_notify_error(NULL, NULL, buf, NULL); | |
422 | |
423 g_free(buf); | |
424 g_free(name); | |
425 | |
426 return; | |
427 } | |
428 | |
429 //im->images = g_slist_append(im->images, GINT_TO_POINTER(id)); | |
430 | |
431 /*buf = g_strdup_printf("<IMG ID=\"%d\" SRC=\"file://%s\">", id, filename); | |
432 gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), buf, -1); | |
433 g_free(buf); | |
434 */ | |
435 g_free(name); | |
436 } | |
437 | |
438 | |
439 static void | |
440 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar) | |
441 { | |
442 char buf[BUF_LONG]; | |
443 GtkWidget *window; | |
444 | |
445 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) { | |
446 window = gtk_file_selection_new(_("Insert Image")); | |
447 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); | |
448 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
449 | |
450 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK); | |
451 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)), | |
452 "response", G_CALLBACK(do_insert_image_cb), toolbar); | |
453 | |
454 gtk_widget_show(window); | |
455 toolbar->image_dialog = window; | |
456 } else { | |
457 gtk_widget_destroy(toolbar->image_dialog); | |
458 toolbar->image_dialog = NULL; | |
459 } | |
460 gtk_widget_grab_focus(toolbar->imhtml); | |
461 } | |
462 | |
463 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
464 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
465 close_smiley_dialog(GtkWidget *widget, GdkEvent *event, |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
466 GtkIMHtmlToolbar *toolbar) |
8317 | 467 { |
468 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
|
469 |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
470 if (toolbar->smiley_dialog != NULL) |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
471 { |
8317 | 472 gtk_widget_destroy(toolbar->smiley_dialog); |
473 toolbar->smiley_dialog = NULL; | |
474 } | |
475 } | |
476 | |
477 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
478 static void |
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
479 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) |
8317 | 480 { |
481 char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | |
482 //GaimPlugin *proto = gaim_find_prpl(gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | |
483 | |
484 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml), NULL, smiley_text); //proto->info->name, smiley_text); | |
485 | |
8320
5c6c8d48946f
[gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
486 close_smiley_dialog(NULL, NULL, toolbar); |
8317 | 487 } |
488 | |
489 | |
490 static void add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face) | |
491 { | |
492 GtkWidget *image; | |
493 GtkWidget *button; | |
494 | |
495 image = gtk_image_new_from_file(filename); | |
496 button = gtk_button_new(); | |
497 gtk_container_add(GTK_CONTAINER(button), image); | |
498 g_object_set_data(G_OBJECT(button), "smiley_text", face); | |
499 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar); | |
500 | |
501 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL); | |
502 | |
503 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1); | |
504 | |
505 /* these look really weird with borders */ | |
506 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
507 | |
508 gtk_widget_show(button); | |
509 } | |
510 | |
511 | |
512 static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) { | |
513 while(list) { | |
514 GtkIMHtmlSmiley *cur = list->data; | |
515 if(!strcmp(cur->file, smiley->file)) | |
516 return FALSE; | |
517 list = list->next; | |
518 } | |
519 return TRUE; | |
520 } | |
521 | |
522 | |
523 static void | |
524 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar) | |
525 { | |
526 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) { | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
527 |
8317 | 528 GtkWidget *dialog; |
529 GtkWidget *smiley_table = NULL; | |
530 GSList *smileys, *unique_smileys = NULL; | |
531 int width; | |
532 int row = 0, col = 0; | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
533 |
8317 | 534 if (toolbar->smiley_dialog) { |
535 gtk_widget_grab_focus(toolbar->imhtml); | |
536 return; | |
537 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
538 |
8317 | 539 /* |
540 if(c->account) | |
541 smileys = get_proto_smileys( | |
542 gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | |
543 else | |
544 */ | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
545 |
8317 | 546 smileys = get_proto_smileys(GAIM_PROTO_DEFAULT); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
547 |
8317 | 548 while(smileys) { |
549 GtkIMHtmlSmiley *smiley = smileys->data; | |
550 if(!smiley->hidden) { | |
551 if(smiley_is_unique(unique_smileys, smiley)) | |
552 unique_smileys = g_slist_append(unique_smileys, smiley); | |
553 } | |
554 smileys = smileys->next; | |
555 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
556 |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
557 |
8317 | 558 width = floor(sqrt(g_slist_length(unique_smileys))); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
559 |
8317 | 560 GAIM_DIALOG(dialog); |
561 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
562 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); | |
563 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
|
564 |
8317 | 565 smiley_table = gtk_table_new(width, width, TRUE); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
566 |
8317 | 567 /* pack buttons */ |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
568 |
8317 | 569 while(unique_smileys) { |
570 GtkIMHtmlSmiley *smiley = unique_smileys->data; | |
571 if(!smiley->hidden) { | |
572 add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile); | |
573 if(++col >= width) { | |
574 col = 0; | |
575 row++; | |
576 } | |
577 } | |
578 unique_smileys = unique_smileys->next; | |
579 } | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
580 |
8317 | 581 gtk_container_add(GTK_CONTAINER(dialog), smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
582 |
8317 | 583 gtk_widget_show(smiley_table); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
584 |
8317 | 585 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
586 |
8317 | 587 /* connect signals */ |
588 g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog"); | |
589 g_signal_connect(G_OBJECT(dialog), "delete_event", | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
590 G_CALLBACK(close_smiley_dialog), toolbar); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
591 |
8317 | 592 /* show everything */ |
593 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!")); | |
594 gtk_widget_show_all(dialog); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
595 |
8317 | 596 toolbar->smiley_dialog = dialog; |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
597 |
8317 | 598 } else if (toolbar->smiley_dialog) { |
8320
5c6c8d48946f
[gaim-migrate @ 9044]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
599 close_smiley_dialog(smiley, NULL, toolbar); |
8317 | 600 } |
601 gtk_widget_grab_focus(toolbar->imhtml); | |
602 } | |
603 | |
604 enum { | |
605 LAST_SIGNAL | |
606 }; | |
607 //static guint signals [LAST_SIGNAL] = { 0 }; | |
608 | |
609 static void | |
610 gtk_imhtmltoolbar_finalize (GObject *object) | |
611 { | |
612 /*GtkIMHtml *imhtml = GTK_IMHTML(object); | |
613 GList *scalables; | |
614 | |
615 g_hash_table_destroy(imhtml->smiley_data); | |
616 gtk_smiley_tree_destroy(imhtml->default_smilies); | |
617 gdk_cursor_unref(imhtml->hand_cursor); | |
618 gdk_cursor_unref(imhtml->arrow_cursor); | |
619 gdk_cursor_unref(imhtml->text_cursor); | |
620 if(imhtml->tip_window){ | |
621 gtk_widget_destroy(imhtml->tip_window); | |
622 } | |
623 if(imhtml->tip_timer) | |
624 gtk_timeout_remove(imhtml->tip_timer); | |
625 | |
626 for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { | |
627 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(scalables->data); | |
628 scale->free(scale); | |
629 } | |
630 | |
631 g_list_free(imhtml->scalables); | |
632 G_OBJECT_CLASS(parent_class)->finalize (object);*/ | |
633 } | |
634 | |
635 /* Boring GTK stuff */ | |
636 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class) | |
637 { | |
638 GtkObjectClass *object_class; | |
639 GObjectClass *gobject_class; | |
640 object_class = (GtkObjectClass*) class; | |
641 gobject_class = (GObjectClass*) class; | |
642 parent_class = gtk_type_class(GTK_TYPE_VBOX); | |
643 /* signals[URL_CLICKED] = g_signal_new(url_clicked", | |
644 G_TYPE_FROM_CLASS(gobject_class), | |
645 G_SIGNAL_RUN_FIRST, | |
646 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
647 NULL, | |
648 0, | |
649 g_cclosure_marshal_VOID__POINTER, | |
650 G_TYPE_NONE, 1, | |
651 G_TYPE_POINTER);*/ | |
652 gobject_class->finalize = gtk_imhtmltoolbar_finalize; | |
653 } | |
654 | |
655 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar) | |
656 { | |
657 GtkWidget *hbox; | |
658 GtkWidget *button; | |
659 GtkWidget *sep; | |
660 GtkSizeGroup *sg; | |
661 | |
662 toolbar->imhtml = NULL; | |
663 toolbar->font_dialog = NULL; | |
664 toolbar->fgcolor_dialog = NULL; | |
665 toolbar->bgcolor_dialog = NULL; | |
666 toolbar->link_dialog = NULL; | |
667 toolbar->smiley_dialog = NULL; | |
668 toolbar->image_dialog = NULL; | |
669 | |
670 toolbar->tooltips = gtk_tooltips_new(); | |
671 | |
672 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
673 | |
674 sep = gtk_hseparator_new(); | |
675 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
676 gtk_widget_show(sep); | |
677 | |
678 hbox = gtk_hbox_new(FALSE, 6); | |
679 gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0); | |
680 | |
681 /* Bold */ | |
682 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
683 gtk_size_group_add_widget(sg, button); | |
684 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
685 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL); | |
686 | |
687 g_signal_connect(G_OBJECT(button), "clicked", | |
688 G_CALLBACK(do_bold), toolbar); | |
689 | |
690 toolbar->bold = button; | |
691 | |
692 /* Italic */ | |
693 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
694 gtk_size_group_add_widget(sg, button); | |
695 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
696 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL); | |
697 | |
698 g_signal_connect(G_OBJECT(button), "clicked", | |
699 G_CALLBACK(do_italic), toolbar); | |
700 | |
701 toolbar->italic = button; | |
702 | |
703 /* Underline */ | |
704 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
705 gtk_size_group_add_widget(sg, button); | |
706 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
707 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL); | |
708 | |
709 g_signal_connect(G_OBJECT(button), "clicked", | |
710 G_CALLBACK(do_underline), toolbar); | |
711 | |
712 toolbar->underline = button; | |
713 | |
714 /* Sep */ | |
715 sep = gtk_vseparator_new(); | |
716 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
717 | |
718 /* Increase font size */ | |
719 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
720 gtk_size_group_add_widget(sg, button); | |
721 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
722 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
723 _("Larger font size"), NULL); | |
724 | |
725 g_signal_connect(G_OBJECT(button), "clicked", | |
726 G_CALLBACK(do_big), toolbar); | |
727 | |
728 toolbar->larger_size = button; | |
729 | |
730 /* Decrease font size */ | |
731 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
732 gtk_size_group_add_widget(sg, button); | |
733 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
734 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
735 _("Smaller font size"), NULL); | |
736 | |
737 g_signal_connect(G_OBJECT(button), "clicked", | |
738 G_CALLBACK(do_small), toolbar); | |
739 | |
740 toolbar->smaller_size = button; | |
741 | |
742 /* Sep */ | |
743 sep = gtk_vseparator_new(); | |
744 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
745 | |
746 /* Font Face */ | |
747 | |
748 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
749 gtk_size_group_add_widget(sg, button); | |
750 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
751 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
752 _("Font Face"), NULL); | |
753 | |
754 g_signal_connect(G_OBJECT(button), "clicked", | |
755 G_CALLBACK(toggle_font), toolbar); | |
756 | |
757 toolbar->font = button; | |
758 | |
759 /* Foreground Color */ | |
760 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
761 gtk_size_group_add_widget(sg, button); | |
762 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
763 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
764 _("Foreground font color"), NULL); | |
765 | |
766 g_signal_connect(G_OBJECT(button), "clicked", | |
767 G_CALLBACK(toggle_fg_color), toolbar); | |
768 | |
769 toolbar->fgcolor = button; | |
770 | |
771 /* Background Color */ | |
772 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
773 gtk_size_group_add_widget(sg, button); | |
774 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
775 gtk_tooltips_set_tip(toolbar->tooltips, button, | |
776 _("Background color"), NULL); | |
777 | |
778 g_signal_connect(G_OBJECT(button), "clicked", | |
779 G_CALLBACK(toggle_bg_color), toolbar); | |
780 | |
781 toolbar->bgcolor = button; | |
782 | |
783 /* Sep */ | |
784 sep = gtk_vseparator_new(); | |
785 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
786 | |
787 /* Insert Link */ | |
788 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
789 gtk_size_group_add_widget(sg, button); | |
790 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
791 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL); | |
792 g_signal_connect(G_OBJECT(button), "clicked", | |
793 G_CALLBACK(insert_link_cb), toolbar); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
794 |
8317 | 795 toolbar->link = button; |
796 | |
797 /* Insert IM Image */ | |
798 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
799 gtk_size_group_add_widget(sg, button); | |
800 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
801 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert image"), NULL); | |
802 | |
803 g_signal_connect(G_OBJECT(button), "clicked", | |
804 G_CALLBACK(insert_image_cb), toolbar); | |
805 | |
806 toolbar->image = button; | |
807 | |
808 /* Insert Smiley */ | |
809 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
810 gtk_size_group_add_widget(sg, button); | |
811 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
812 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL); | |
813 | |
814 g_signal_connect(G_OBJECT(button), "clicked", | |
815 G_CALLBACK(insert_smiley_cb), toolbar); | |
816 | |
817 toolbar->smiley = button; | |
818 | |
819 | |
820 sep = gtk_hseparator_new(); | |
821 gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
822 gtk_widget_show(sep); | |
823 | |
824 | |
825 //if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
826 // gtk_widget_hide(vbox); | |
827 | |
828 gtk_widget_show_all(hbox); | |
829 } | |
830 | |
831 GtkWidget *gtk_imhtmltoolbar_new() | |
832 { | |
833 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL)); | |
834 } | |
835 | |
836 GType gtk_imhtmltoolbar_get_type() | |
837 { | |
838 static GType imhtmltoolbar_type = 0; | |
839 | |
840 if (!imhtmltoolbar_type) { | |
841 static const GTypeInfo imhtmltoolbar_info = { | |
842 sizeof(GtkIMHtmlToolbarClass), | |
843 NULL, | |
844 NULL, | |
845 (GClassInitFunc) gtk_imhtmltoolbar_class_init, | |
846 NULL, | |
847 NULL, | |
848 sizeof (GtkIMHtmlToolbar), | |
849 0, | |
850 (GInstanceInitFunc) gtk_imhtmltoolbar_init | |
851 }; | |
852 | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
853 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_VBOX, |
8317 | 854 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0); |
855 } | |
856 | |
857 return imhtmltoolbar_type; | |
858 } | |
859 | |
860 | |
8324
2df8b01af581
[gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents:
8322
diff
changeset
|
861 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml) |
8317 | 862 { |
8325
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
863 g_return_if_fail(toolbar != NULL); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
864 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar)); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
865 g_return_if_fail(imhtml != NULL); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
866 g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
415283e39bce
[gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents:
8324
diff
changeset
|
867 |
8317 | 868 toolbar->imhtml = imhtml; |
869 } |