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