annotate src/gtkimhtmltoolbar.c @ 8788:262f81346c0a

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