Mon, 23 Feb 2004 22:13:43 +0000
[gaim-migrate @ 9043]
This fixes the symbol collision, incorrect data types, lack of casting,
unused variables, and comments inside comments that were preventing the new
toolbar code from compiling in some cases here.
| 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 | ||
| 436 | void close_smiley_dialog(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) | |
| 437 | { | |
| 438 | 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
|
439 | |
| 8317 | 440 | if (toolbar->smiley_dialog) { |
| 441 | gtk_widget_destroy(toolbar->smiley_dialog); | |
| 442 | toolbar->smiley_dialog = NULL; | |
| 443 | } | |
| 444 | } | |
| 445 | ||
| 446 | ||
| 447 | void insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar) | |
| 448 | { | |
| 449 | char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | |
| 450 | //GaimPlugin *proto = gaim_find_prpl(gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | |
| 451 | ||
| 452 | gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml), NULL, smiley_text); //proto->info->name, smiley_text); | |
| 453 | ||
| 454 | close_smiley_dialog(NULL, toolbar); | |
| 455 | } | |
| 456 | ||
| 457 | ||
| 458 | static void add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face) | |
| 459 | { | |
| 460 | GtkWidget *image; | |
| 461 | GtkWidget *button; | |
| 462 | ||
| 463 | image = gtk_image_new_from_file(filename); | |
| 464 | button = gtk_button_new(); | |
| 465 | gtk_container_add(GTK_CONTAINER(button), image); | |
| 466 | g_object_set_data(G_OBJECT(button), "smiley_text", face); | |
| 467 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar); | |
| 468 | ||
| 469 | gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL); | |
| 470 | ||
| 471 | gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1); | |
| 472 | ||
| 473 | /* these look really weird with borders */ | |
| 474 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
| 475 | ||
| 476 | gtk_widget_show(button); | |
| 477 | } | |
| 478 | ||
| 479 | ||
| 480 | static gboolean smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) { | |
| 481 | while(list) { | |
| 482 | GtkIMHtmlSmiley *cur = list->data; | |
| 483 | if(!strcmp(cur->file, smiley->file)) | |
| 484 | return FALSE; | |
| 485 | list = list->next; | |
| 486 | } | |
| 487 | return TRUE; | |
| 488 | } | |
| 489 | ||
| 490 | ||
| 491 | static void | |
| 492 | insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar) | |
| 493 | { | |
| 494 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) { | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
495 | |
| 8317 | 496 | GtkWidget *dialog; |
| 497 | GtkWidget *smiley_table = NULL; | |
| 498 | GSList *smileys, *unique_smileys = NULL; | |
| 499 | int width; | |
| 500 | int row = 0, col = 0; | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
501 | |
| 8317 | 502 | if (toolbar->smiley_dialog) { |
| 503 | gtk_widget_grab_focus(toolbar->imhtml); | |
| 504 | return; | |
| 505 | } | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
506 | |
| 8317 | 507 | /* |
| 508 | if(c->account) | |
| 509 | smileys = get_proto_smileys( | |
| 510 | gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | |
| 511 | else | |
| 512 | */ | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
513 | |
| 8317 | 514 | smileys = get_proto_smileys(GAIM_PROTO_DEFAULT); |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
515 | |
| 8317 | 516 | while(smileys) { |
| 517 | GtkIMHtmlSmiley *smiley = smileys->data; | |
| 518 | if(!smiley->hidden) { | |
| 519 | if(smiley_is_unique(unique_smileys, smiley)) | |
| 520 | unique_smileys = g_slist_append(unique_smileys, smiley); | |
| 521 | } | |
| 522 | smileys = smileys->next; | |
| 523 | } | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
524 | |
|
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
525 | |
| 8317 | 526 | width = floor(sqrt(g_slist_length(unique_smileys))); |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
527 | |
| 8317 | 528 | GAIM_DIALOG(dialog); |
| 529 | gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
| 530 | gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog"); | |
| 531 | 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
|
532 | |
| 8317 | 533 | smiley_table = gtk_table_new(width, width, TRUE); |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
534 | |
| 8317 | 535 | /* pack buttons */ |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
536 | |
| 8317 | 537 | while(unique_smileys) { |
| 538 | GtkIMHtmlSmiley *smiley = unique_smileys->data; | |
| 539 | if(!smiley->hidden) { | |
| 540 | add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile); | |
| 541 | if(++col >= width) { | |
| 542 | col = 0; | |
| 543 | row++; | |
| 544 | } | |
| 545 | } | |
| 546 | unique_smileys = unique_smileys->next; | |
| 547 | } | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
548 | |
| 8317 | 549 | gtk_container_add(GTK_CONTAINER(dialog), smiley_table); |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
550 | |
| 8317 | 551 | gtk_widget_show(smiley_table); |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
552 | |
| 8317 | 553 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
554 | |
| 8317 | 555 | /* connect signals */ |
| 556 | g_object_set_data(G_OBJECT(dialog), "dialog_type", "smiley dialog"); | |
| 557 | g_signal_connect(G_OBJECT(dialog), "delete_event", | |
| 558 | G_CALLBACK(close_smiley_dialog), toolbar); | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
559 | |
| 8317 | 560 | /* show everything */ |
| 561 | gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!")); | |
| 562 | gtk_widget_show_all(dialog); | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
563 | |
| 8317 | 564 | toolbar->smiley_dialog = dialog; |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
565 | |
| 8317 | 566 | } else if (toolbar->smiley_dialog) { |
| 567 | close_smiley_dialog(smiley, toolbar); | |
| 568 | } | |
| 569 | gtk_widget_grab_focus(toolbar->imhtml); | |
| 570 | } | |
| 571 | ||
| 572 | enum { | |
| 573 | LAST_SIGNAL | |
| 574 | }; | |
| 575 | //static guint signals [LAST_SIGNAL] = { 0 }; | |
| 576 | ||
| 577 | static void | |
| 578 | gtk_imhtmltoolbar_finalize (GObject *object) | |
| 579 | { | |
| 580 | /*GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 581 | GList *scalables; | |
| 582 | ||
| 583 | g_hash_table_destroy(imhtml->smiley_data); | |
| 584 | gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 585 | gdk_cursor_unref(imhtml->hand_cursor); | |
| 586 | gdk_cursor_unref(imhtml->arrow_cursor); | |
| 587 | gdk_cursor_unref(imhtml->text_cursor); | |
| 588 | if(imhtml->tip_window){ | |
| 589 | gtk_widget_destroy(imhtml->tip_window); | |
| 590 | } | |
| 591 | if(imhtml->tip_timer) | |
| 592 | gtk_timeout_remove(imhtml->tip_timer); | |
| 593 | ||
| 594 | for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { | |
| 595 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(scalables->data); | |
| 596 | scale->free(scale); | |
| 597 | } | |
| 598 | ||
| 599 | g_list_free(imhtml->scalables); | |
| 600 | G_OBJECT_CLASS(parent_class)->finalize (object);*/ | |
| 601 | } | |
| 602 | ||
| 603 | /* Boring GTK stuff */ | |
| 604 | static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class) | |
| 605 | { | |
| 606 | GtkObjectClass *object_class; | |
| 607 | GObjectClass *gobject_class; | |
| 608 | object_class = (GtkObjectClass*) class; | |
| 609 | gobject_class = (GObjectClass*) class; | |
| 610 | parent_class = gtk_type_class(GTK_TYPE_VBOX); | |
| 611 | /* signals[URL_CLICKED] = g_signal_new(url_clicked", | |
| 612 | G_TYPE_FROM_CLASS(gobject_class), | |
| 613 | G_SIGNAL_RUN_FIRST, | |
| 614 | G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 615 | NULL, | |
| 616 | 0, | |
| 617 | g_cclosure_marshal_VOID__POINTER, | |
| 618 | G_TYPE_NONE, 1, | |
| 619 | G_TYPE_POINTER);*/ | |
| 620 | gobject_class->finalize = gtk_imhtmltoolbar_finalize; | |
| 621 | } | |
| 622 | ||
| 623 | static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar) | |
| 624 | { | |
| 625 | GtkWidget *hbox; | |
| 626 | GtkWidget *button; | |
| 627 | GtkWidget *sep; | |
| 628 | GtkSizeGroup *sg; | |
| 629 | ||
| 630 | toolbar->imhtml = NULL; | |
| 631 | toolbar->font_dialog = NULL; | |
| 632 | toolbar->fgcolor_dialog = NULL; | |
| 633 | toolbar->bgcolor_dialog = NULL; | |
| 634 | toolbar->link_dialog = NULL; | |
| 635 | toolbar->smiley_dialog = NULL; | |
| 636 | toolbar->image_dialog = NULL; | |
| 637 | ||
| 638 | toolbar->tooltips = gtk_tooltips_new(); | |
| 639 | ||
| 640 | sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
| 641 | ||
| 642 | sep = gtk_hseparator_new(); | |
| 643 | gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
| 644 | gtk_widget_show(sep); | |
| 645 | ||
| 646 | hbox = gtk_hbox_new(FALSE, 6); | |
| 647 | gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0); | |
| 648 | ||
| 649 | /* Bold */ | |
| 650 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
| 651 | gtk_size_group_add_widget(sg, button); | |
| 652 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 653 | gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL); | |
| 654 | ||
| 655 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 656 | G_CALLBACK(do_bold), toolbar); | |
| 657 | ||
| 658 | toolbar->bold = button; | |
| 659 | ||
| 660 | /* Italic */ | |
| 661 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
| 662 | gtk_size_group_add_widget(sg, button); | |
| 663 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 664 | gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL); | |
| 665 | ||
| 666 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 667 | G_CALLBACK(do_italic), toolbar); | |
| 668 | ||
| 669 | toolbar->italic = button; | |
| 670 | ||
| 671 | /* Underline */ | |
| 672 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
| 673 | gtk_size_group_add_widget(sg, button); | |
| 674 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 675 | gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL); | |
| 676 | ||
| 677 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 678 | G_CALLBACK(do_underline), toolbar); | |
| 679 | ||
| 680 | toolbar->underline = button; | |
| 681 | ||
| 682 | /* Sep */ | |
| 683 | sep = gtk_vseparator_new(); | |
| 684 | gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
| 685 | ||
| 686 | /* Increase font size */ | |
| 687 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
| 688 | gtk_size_group_add_widget(sg, button); | |
| 689 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 690 | gtk_tooltips_set_tip(toolbar->tooltips, button, | |
| 691 | _("Larger font size"), NULL); | |
| 692 | ||
| 693 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 694 | G_CALLBACK(do_big), toolbar); | |
| 695 | ||
| 696 | toolbar->larger_size = button; | |
| 697 | ||
| 698 | /* Decrease font size */ | |
| 699 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
| 700 | gtk_size_group_add_widget(sg, button); | |
| 701 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 702 | gtk_tooltips_set_tip(toolbar->tooltips, button, | |
| 703 | _("Smaller font size"), NULL); | |
| 704 | ||
| 705 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 706 | G_CALLBACK(do_small), toolbar); | |
| 707 | ||
| 708 | toolbar->smaller_size = button; | |
| 709 | ||
| 710 | /* Sep */ | |
| 711 | sep = gtk_vseparator_new(); | |
| 712 | gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
| 713 | ||
| 714 | /* Font Face */ | |
| 715 | ||
| 716 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
| 717 | gtk_size_group_add_widget(sg, button); | |
| 718 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 719 | gtk_tooltips_set_tip(toolbar->tooltips, button, | |
| 720 | _("Font Face"), NULL); | |
| 721 | ||
| 722 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 723 | G_CALLBACK(toggle_font), toolbar); | |
| 724 | ||
| 725 | toolbar->font = button; | |
| 726 | ||
| 727 | /* Foreground Color */ | |
| 728 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
| 729 | gtk_size_group_add_widget(sg, button); | |
| 730 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 731 | gtk_tooltips_set_tip(toolbar->tooltips, button, | |
| 732 | _("Foreground font color"), NULL); | |
| 733 | ||
| 734 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 735 | G_CALLBACK(toggle_fg_color), toolbar); | |
| 736 | ||
| 737 | toolbar->fgcolor = button; | |
| 738 | ||
| 739 | /* Background Color */ | |
| 740 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
| 741 | gtk_size_group_add_widget(sg, button); | |
| 742 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 743 | gtk_tooltips_set_tip(toolbar->tooltips, button, | |
| 744 | _("Background color"), NULL); | |
| 745 | ||
| 746 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 747 | G_CALLBACK(toggle_bg_color), toolbar); | |
| 748 | ||
| 749 | toolbar->bgcolor = button; | |
| 750 | ||
| 751 | /* Sep */ | |
| 752 | sep = gtk_vseparator_new(); | |
| 753 | gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
| 754 | ||
| 755 | /* Insert Link */ | |
| 756 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
| 757 | gtk_size_group_add_widget(sg, button); | |
| 758 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 759 | gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL); | |
| 760 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 761 | G_CALLBACK(insert_link_cb), toolbar); | |
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
762 | |
| 8317 | 763 | toolbar->link = button; |
| 764 | ||
| 765 | /* Insert IM Image */ | |
| 766 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
| 767 | gtk_size_group_add_widget(sg, button); | |
| 768 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 769 | gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert image"), NULL); | |
| 770 | ||
| 771 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 772 | G_CALLBACK(insert_image_cb), toolbar); | |
| 773 | ||
| 774 | toolbar->image = button; | |
| 775 | ||
| 776 | /* Insert Smiley */ | |
| 777 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
| 778 | gtk_size_group_add_widget(sg, button); | |
| 779 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 780 | gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL); | |
| 781 | ||
| 782 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 783 | G_CALLBACK(insert_smiley_cb), toolbar); | |
| 784 | ||
| 785 | toolbar->smiley = button; | |
| 786 | ||
| 787 | ||
| 788 | sep = gtk_hseparator_new(); | |
| 789 | gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0); | |
| 790 | gtk_widget_show(sep); | |
| 791 | ||
| 792 | ||
| 793 | //if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
| 794 | // gtk_widget_hide(vbox); | |
| 795 | ||
| 796 | gtk_widget_show_all(hbox); | |
| 797 | } | |
| 798 | ||
| 799 | GtkWidget *gtk_imhtmltoolbar_new() | |
| 800 | { | |
| 801 | return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL)); | |
| 802 | } | |
| 803 | ||
| 804 | GType gtk_imhtmltoolbar_get_type() | |
| 805 | { | |
| 806 | static GType imhtmltoolbar_type = 0; | |
| 807 | ||
| 808 | if (!imhtmltoolbar_type) { | |
| 809 | static const GTypeInfo imhtmltoolbar_info = { | |
| 810 | sizeof(GtkIMHtmlToolbarClass), | |
| 811 | NULL, | |
| 812 | NULL, | |
| 813 | (GClassInitFunc) gtk_imhtmltoolbar_class_init, | |
| 814 | NULL, | |
| 815 | NULL, | |
| 816 | sizeof (GtkIMHtmlToolbar), | |
| 817 | 0, | |
| 818 | (GInstanceInitFunc) gtk_imhtmltoolbar_init | |
| 819 | }; | |
| 820 | ||
|
8319
6c18762beceb
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
821 | imhtmltoolbar_type = g_type_register_static(GTK_TYPE_VBOX, |
| 8317 | 822 | "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0); |
| 823 | } | |
| 824 | ||
| 825 | return imhtmltoolbar_type; | |
| 826 | } | |
| 827 | ||
| 828 | ||
| 829 | void gtk_imhtmltoolbar_attach (GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml) | |
| 830 | { | |
| 831 | toolbar->imhtml = imhtml; | |
| 832 | } |