annotate src/gtkimhtmltoolbar.c @ 10589:0f7452b1f777

[gaim-migrate @ 11994] Use GLib 2.6's gstdio functions. This should fix gaim not liking non-ascii filenames in win32. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 Feb 2005 05:10:40 +0000
parents 1a97d5e88d12
children c4cb90065e1d
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 /*
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10138
diff changeset
2 * @file gtkimhtmltoolbar.c GTK+ IMHtml Toolbar
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10138
diff changeset
3 * @ingroup gtkui
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10138
diff changeset
4 *
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10138
diff changeset
5 * gaim
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * 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
8 * to list here. Please refer to the COPYRIGHT file distributed with this
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * source distribution.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * under the terms of the GNU General Public License as published by
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
26 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
27 #include "gtkgaim.h"
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
29 #include "imgstore.h"
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "notify.h"
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "request.h"
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10138
diff changeset
32 #include "gtkstock.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
9730
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
35 #include "gtkdialogs.h"
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
36 #include "gtkimhtmltoolbar.h"
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
37 #include "gtkutils.h"
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
38
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
39 static GtkHBoxClass *parent_class = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
43 GObject *object;
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
44
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 g_return_if_fail(toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
46
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
47 /* block the format_function_toggle handler */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
48 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml)));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
49 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
50 NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml));
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
52 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
53 NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
54 g_object_unref(object);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
55
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
62 GObject *object;
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
63
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 g_return_if_fail(toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
65
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
66 /* block the format_function_toggle handler */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
67 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml)));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
68 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
69 NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml));
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
71 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
72 NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
73 g_object_unref(object);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
74
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
81 GObject *object;
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
82
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 g_return_if_fail(toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
84
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
85 /* block the format_function_toggle handler */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
86 object = g_object_ref(G_OBJECT(GTK_IMHTML(toolbar->imhtml)));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
87 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
88 NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml));
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
90 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
91 NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
92 g_object_unref(object);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
93
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 gtk_widget_grab_focus(toolbar->imhtml);
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
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 g_return_if_fail(toolbar);
8380
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8359
diff changeset
101 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
102 gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 gtk_widget_grab_focus(toolbar->imhtml);
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
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 do_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 g_return_if_fail(toolbar);
8380
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8359
diff changeset
111 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
112 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
117 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
118 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
119 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 {
10135
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
121 if (widget != NULL)
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
122 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->font), FALSE);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
124 if (toolbar->font_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
125 {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 gtk_widget_destroy(toolbar->font_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 toolbar->font_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
131 static void
10125
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
132 realize_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
133 {
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
134 GtkFontSelection *sel;
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
135
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
136 sel = GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->fontsel);
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
137 gtk_widget_hide_all(gtk_widget_get_parent(sel->size_entry));
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
138 gtk_widget_show_all(sel->family_list);
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
139 gtk_widget_show(gtk_widget_get_parent(sel->family_list));
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
140 gtk_widget_show(gtk_widget_get_parent(gtk_widget_get_parent(sel->family_list)));
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
141 }
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
142
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
143 static void
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
144 cancel_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
145 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
146 destroy_toolbar_font(widget, NULL, toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
147 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
148
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 static void apply_font(GtkWidget *widget, GtkFontSelection *fontsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 /* this could be expanded to include font size, weight, etc.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 but for now only works with font face */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 char *fontname;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 char *space;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 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
158
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 space = strrchr(fontname, ' ');
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 if(space && isdigit(*(space+1)))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 *space = '\0';
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 g_free(fontname);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
167 cancel_toolbar_font(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 {
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
173 char *fontname;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
174
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 g_return_if_fail(toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
176
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
177 fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
178
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 if (!toolbar->font_dialog) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 g_object_set_data(G_OBJECT(toolbar->font_dialog), "gaim_toolbar", toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
183
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
184 if(fontname) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
185 char fonttif[128];
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
186 g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontname);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
187 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
188 fonttif);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
189 g_free(fontname);
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
190 } else {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
191 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
192 DEFAULT_FONT_FACE);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
193 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
194
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
196 G_CALLBACK(destroy_toolbar_font), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
197 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
198 G_CALLBACK(apply_font), toolbar->font_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
199 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
200 G_CALLBACK(cancel_toolbar_font), toolbar);
10125
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
201 g_signal_connect_after(G_OBJECT(toolbar->font_dialog), "realize",
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
202 G_CALLBACK(realize_toolbar_font), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
203
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 gtk_window_present(GTK_WINDOW(toolbar->font_dialog));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 } else {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
206 cancel_toolbar_font(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 gtk_widget_grab_focus(toolbar->imhtml);
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
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
211 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
212 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
213 GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
214 {
10135
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
215 if (widget != NULL)
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
216 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->fgcolor), FALSE);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
217
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
218 if (toolbar->fgcolor_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
219 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
220 gtk_widget_destroy(toolbar->fgcolor_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
221 toolbar->fgcolor_dialog = NULL;
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
222 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
223 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
224
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
225 static void cancel_toolbar_fgcolor(GtkWidget *widget,
8321
eb269b81fff8 [gaim-migrate @ 9045]
Christian Hammond <chipx86@chipx86.com>
parents: 8320
diff changeset
226 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
228 destroy_toolbar_fgcolor(widget, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 static void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GdkColor text_color;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 char *open_tag;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 open_tag = g_malloc(30);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 gtk_color_selection_get_current_color(colorsel, &text_color);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 g_snprintf(open_tag, 23, "#%02X%02X%02X",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 text_color.red / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 text_color.green / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 text_color.blue / 256);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_free(open_tag);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
246 cancel_toolbar_fgcolor(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 toggle_fg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 GtkWidget *colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
254 GdkColor fgcolor;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
255 char *color = gtk_imhtml_get_current_forecolor(GTK_IMHTML(toolbar->imhtml));
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
256
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 if (!toolbar->fgcolor_dialog) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
258
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
261 if (color) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
262 gdk_color_parse(color, &fgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
263 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
264 g_free(color);
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
265 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
266
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
268
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
270 G_CALLBACK(destroy_toolbar_fgcolor), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
271 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
272 G_CALLBACK(do_fgcolor), colorsel);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
273 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
274 G_CALLBACK(cancel_toolbar_fgcolor), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
275
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
277 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 } else if (toolbar->fgcolor_dialog != NULL) {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
279 cancel_toolbar_fgcolor(color, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 } else {
9863
0e3a84f18467 [gaim-migrate @ 10742]
Mark Doliner <mark@kingant.net>
parents: 9791
diff changeset
281 /* gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); */
8317
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 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
286 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
287 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
288 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 {
10135
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
290 if (widget != NULL)
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
291 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
292
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
293 if (toolbar->bgcolor_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
294 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
295 gtk_widget_destroy(toolbar->bgcolor_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
296 toolbar->bgcolor_dialog = NULL;
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
297 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
298 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
299
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
300 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
301 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
302 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
303 destroy_toolbar_bgcolor(widget, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 GdkColor text_color;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 char *open_tag;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 open_tag = g_malloc(30);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 gtk_color_selection_get_current_color(colorsel, &text_color);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 g_snprintf(open_tag, 23, "#%02X%02X%02X",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 text_color.red / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 text_color.green / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 text_color.blue / 256);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 g_free(open_tag);
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
321 cancel_toolbar_bgcolor(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 GtkWidget *colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
329 GdkColor bgcolor;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
330 char *color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(toolbar->imhtml));
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
331
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 if (!toolbar->bgcolor_dialog) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
333
8359
05c174138e94 [gaim-migrate @ 9083]
Mark Doliner <mark@kingant.net>
parents: 8325
diff changeset
334 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color"));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
336 if (color) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
337 gdk_color_parse(color, &bgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
338 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
339 g_free(color);
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
340 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
341
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
343
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
345 G_CALLBACK(destroy_toolbar_bgcolor), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
346 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
347 G_CALLBACK(do_bgcolor), colorsel);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
348 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
349 G_CALLBACK(cancel_toolbar_bgcolor), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
350
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
352 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 } else if (toolbar->bgcolor_dialog != NULL) {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
354 cancel_toolbar_bgcolor(color, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 } else {
9863
0e3a84f18467 [gaim-migrate @ 10742]
Mark Doliner <mark@kingant.net>
parents: 9791
diff changeset
356 /* gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); */
8317
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 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 cancel_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
364 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
365
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 }
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 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 close_link_dialog(GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 if (toolbar->link_dialog != NULL)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 const char *url, *description;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 url = gaim_request_fields_get_string(fields, "url");
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
385 if (GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC)
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
386 description = gaim_request_fields_get_string(fields, "description");
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
387 else
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
388 description = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 if (description == NULL)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 description = url;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
393 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
394 gtk_text_buffer_get_insert(GTK_IMHTML(toolbar->imhtml)->text_buffer),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
395 url, description);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
396
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 GaimRequestFields *fields;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 GaimRequestFieldGroup *group;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 GaimRequestField *field;
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
409 GtkTextIter start, end;
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
410 char *msg;
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
411 char *desc = NULL;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
412
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 fields = gaim_request_fields_new();
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
414
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 group = gaim_request_field_group_new(NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 gaim_request_fields_add_group(fields, group);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
417
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 gaim_request_field_set_required(field, TRUE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 gaim_request_field_group_add_field(group, field);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
421
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
422 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) {
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
423 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, &start, &end)) {
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
424 desc = gtk_imhtml_get_text(GTK_IMHTML(toolbar->imhtml), &start, &end);
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
425 }
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
426 field = gaim_request_field_string_new("description", _("_Description"),
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
427 desc, FALSE);
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
428 gaim_request_field_group_add_field(group, field);
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
429 msg = g_strdup(_("Please enter the URL and description of the "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
430 "link that you want to insert. The description "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
431 "is optional."));
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
432 } else {
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
433 msg = g_strdup(_("Please enter the URL of the "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
434 "link that you want to insert."));
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
435 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
436
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 toolbar->link_dialog =
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 gaim_request_fields(toolbar, _("Insert Link"),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 NULL,
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
440 msg,
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 fields,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 _("_Insert"), G_CALLBACK(do_insert_link_cb),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 _("Cancel"), G_CALLBACK(cancel_link_cb),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 toolbar);
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
445 g_free(msg);
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
446 g_free(desc);
8322
ffb601c6b833 [gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents: 8321
diff changeset
447 } else {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 close_link_dialog(toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452
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 static void
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
455 do_insert_image_cb(GtkWidget *widget, int response, GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 {
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
457 gchar *filename, *name, *buf;
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
458 char *filedata;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 size_t size;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 GError *error = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 int id;
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
462 GtkTextIter iter;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
463 GtkTextMark *ins;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
465 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
466 if (response != GTK_RESPONSE_ACCEPT) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
467 #else /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
468 if (response != GTK_RESPONSE_OK) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
469 #endif /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 return;
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
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
474 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
475 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
476 #else /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
477 filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget)));
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
478 #endif /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
480 if (filename == NULL) {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
485 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
486 if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(widget))) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
487 g_free(filename);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
488 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
489 return;
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
490 }
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
491 #endif /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
492
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
493 /* The following triggers a callback that closes the widget */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
496 if (!g_file_get_contents(filename, &filedata, &size, &error)) {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 gaim_notify_error(NULL, NULL, error->message, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 g_error_free(error);
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
500 g_free(filename);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
505 name = strrchr(filename, G_DIR_SEPARATOR) + 1;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
507 id = gaim_imgstore_add(filedata, size, name);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 g_free(filedata);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
510 if (id == 0) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
511 buf = g_strdup_printf(_("Failed to store image: %s\n"), filename);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 gaim_notify_error(NULL, NULL, buf, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 g_free(buf);
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
515 g_free(filename);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
520 g_free(filename);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
521
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
522 ins = gtk_text_buffer_get_insert(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)));
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
523 gtk_text_buffer_get_iter_at_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)),
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
524 &iter, ins);
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
525 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(toolbar->imhtml), id, &iter);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
526 gaim_imgstore_unref(id);
8317
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
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 GtkWidget *window;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) {
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
536 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
537 window = gtk_file_chooser_dialog_new(_("Insert Image"),
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
538 NULL,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
539 GTK_FILE_CHOOSER_ACTION_OPEN,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
540 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
541 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
542 NULL);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
543 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_ACCEPT);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
544 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(window)),
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
545 "response", G_CALLBACK(do_insert_image_cb), toolbar);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
546 #else /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 window = gtk_file_selection_new(_("Insert Image"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 "response", G_CALLBACK(do_insert_image_cb), toolbar);
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
551 #endif /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 gtk_widget_show(window);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 toolbar->image_dialog = window;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 } else {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 gtk_widget_destroy(toolbar->image_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 toolbar->image_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 }
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
559
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 gtk_widget_grab_focus(toolbar->imhtml);
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
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
563 #if GTK_CHECK_VERSION(2,4,0) /* Smiley selection menu */
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
564 static void
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
565 smiley_dialog_closed_cb(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 {
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
567 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
568 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
569 #else
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
570 static void
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
571 destroy_smiley_dialog(GtkIMHtmlToolbar *toolbar)
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
572 {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
573 if (toolbar->smiley_dialog != NULL)
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
574 {
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
575 gtk_widget_destroy(toolbar->smiley_dialog);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
576 toolbar->smiley_dialog = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
580 static void
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
581 close_smiley_dialog(GtkWidget *widget, GdkEvent *event,
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
582 GtkIMHtmlToolbar *toolbar)
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
583 {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
584 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
585 }
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
586 #endif
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
588 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
589 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 {
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
591 char *smiley_text, *escaped_smiley;
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
592
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
593 smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text");
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
594 escaped_smiley = gaim_escape_html(smiley_text);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8447
diff changeset
596 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml),
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8447
diff changeset
597 GTK_IMHTML(toolbar->imhtml)->protocol_name,
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
598 escaped_smiley);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
600 g_free(escaped_smiley);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
601
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
602 #if !GTK_CHECK_VERSION(2,4,0) /* Smiley selection menu */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
603 close_smiley_dialog(NULL, NULL, toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
604 #endif
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
607 #if GTK_CHECK_VERSION(2,4,0) /* Smiley selection menu */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
608 static void
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
609 add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *menu, int row, int col, char *filename, char *face)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 GtkWidget *image;
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
612 GtkWidget *menuitem;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 image = gtk_image_new_from_file(filename);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
615 menuitem = gtk_image_menu_item_new_with_label("");
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
616 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
617 g_object_set_data(G_OBJECT(menuitem), "smiley_text", face);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
618 gtk_tooltips_set_tip(toolbar->tooltips, menuitem, face, NULL);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
619 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(insert_smiley_text), toolbar);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
620 gtk_menu_attach(GTK_MENU(menu), menuitem, col, col+1, row, row+1);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 }
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
622 #else
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
623 static void
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
624 add_smiley(GtkIMHtmlToolbar *toolbar, GtkWidget *table, int row, int col, char *filename, char *face)
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
625 {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
626 GtkWidget *image;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
627 GtkWidget *button;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
629 image = gtk_image_new_from_file(filename);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
630 button = gtk_button_new();
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
631 gtk_container_add(GTK_CONTAINER(button), image);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
632 g_object_set_data(G_OBJECT(button), "smiley_text", face);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
633 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
634
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
635 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
636
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
637 gtk_table_attach_defaults(GTK_TABLE(table), button, col, col+1, row, row+1);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
638
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
639 /* these look really weird with borders */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
640 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
641
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
642 gtk_widget_show(button);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
643 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
644 #endif
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
645
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
646 static gboolean
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
647 smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley) {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 while(list) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 GtkIMHtmlSmiley *cur = list->data;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650 if(!strcmp(cur->file, smiley->file))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 return FALSE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 list = list->next;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
658 #if GTK_CHECK_VERSION(2,4,0) /* Smiley selection menu */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 {
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
662 GtkWidget *menu;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
663 GSList *smileys, *unique_smileys = NULL;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
664 int width;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
665 int row = 0, col = 0;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
666
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
667 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley)))
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
668 return;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
669
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
670 if (toolbar->sml)
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
671 smileys = get_proto_smileys(toolbar->sml);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
672 else
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
673 smileys = get_proto_smileys(NULL);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
674
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
675 while(smileys) {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
676 GtkIMHtmlSmiley *smiley = smileys->data;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
677 if(!smiley->hidden) {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
678 if(smiley_is_unique(unique_smileys, smiley))
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
679 unique_smileys = g_slist_append(unique_smileys, smiley);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 }
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
681 smileys = smileys->next;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
682 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
683
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
684 menu = gtk_menu_new();
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
685
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
686 if(g_slist_length(unique_smileys)) {
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
687
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
688 width = floor(sqrt(g_slist_length(unique_smileys)));
8892
ed62fb44aa30 [gaim-migrate @ 9661]
Luke Schierer <lschiere@pidgin.im>
parents: 8807
diff changeset
689
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
690 /* build menu */
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
691 while(unique_smileys) {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
692 GtkIMHtmlSmiley *smiley = unique_smileys->data;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
693 if(!smiley->hidden) {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
694 add_smiley(toolbar, menu, row, col, smiley->file, smiley->smile);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
695
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
696 if(++col >= width) {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
697 col = 0;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
698 row++;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
699 }
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
700 }
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
701 unique_smileys = unique_smileys->next;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
702 }
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
703 }
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
704 else {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
705 GtkWidget *menuitem;
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
706 menuitem = gtk_menu_item_new_with_label(_("This theme has no available smileys."));
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
707 gtk_widget_set_sensitive(menuitem, FALSE);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
708 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
709 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
710
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
711 /*
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
712 * The menu itself is free'd automatically, but we need to un-press
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
713 * the "insert smiley" button whenever the menu is closed.
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
714 *
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
715 * XXX - Make sure the menu really is freed!
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
716 */
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
717 g_signal_connect(G_OBJECT(menu), "deactivate",
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
718 G_CALLBACK(smiley_dialog_closed_cb), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
719
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
720 /* show everything */
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
721 gtk_widget_show_all(menu);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
722 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
723 toolbar->smiley_dialog = menu;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
724
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 }
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
727 #else
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
728 static void
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
729 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar)
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
730 {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
731 GtkWidget *dialog;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
732 GtkWidget *smiley_table = NULL;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
733 GSList *smileys, *unique_smileys = NULL;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
734 int width;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
735 int row = 0, col = 0;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
736
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
737 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
738 destroy_smiley_dialog(toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
739 gtk_widget_grab_focus(toolbar->imhtml);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
740 return;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
741 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
742
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
743 if (toolbar->sml)
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
744 smileys = get_proto_smileys(toolbar->sml);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
745 else
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
746 smileys = get_proto_smileys(NULL);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
747
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
748 while(smileys) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
749 GtkIMHtmlSmiley *smiley = smileys->data;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
750 if(!smiley->hidden) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
751 if(smiley_is_unique(unique_smileys, smiley))
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
752 unique_smileys = g_slist_append(unique_smileys, smiley);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
753 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
754 smileys = smileys->next;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
755 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
756
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
757 GAIM_DIALOG(dialog);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
758
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
759 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
760 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog");
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
761 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
762
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
763 if(g_slist_length(unique_smileys)) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
764
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
765 width = floor(sqrt(g_slist_length(unique_smileys)));
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
766
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
767 smiley_table = gtk_table_new(width, width, TRUE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
768
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
769 /* pack buttons */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
770
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
771 while(unique_smileys) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
772 GtkIMHtmlSmiley *smiley = unique_smileys->data;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
773 if(!smiley->hidden) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
774 add_smiley(toolbar, smiley_table, row, col, smiley->file, smiley->smile);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
775 if(++col >= width) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
776 col = 0;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
777 row++;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
778 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
779 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
780 unique_smileys = unique_smileys->next;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
781 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
782 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
783 else {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
784 smiley_table = gtk_label_new(_("This theme has no available smileys."));
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
785 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
786
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
787 gtk_container_add(GTK_CONTAINER(dialog), smiley_table);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
788
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
789 gtk_widget_show(smiley_table);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
790
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
791 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
792
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
793 /* connect signals */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
794 g_signal_connect(G_OBJECT(dialog), "delete_event",
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
795 G_CALLBACK(close_smiley_dialog), toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
796
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
797 /* show everything */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
798 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!"));
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
799 gtk_widget_show_all(dialog);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
800
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
801 toolbar->smiley_dialog = dialog;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
802
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
803 gtk_widget_grab_focus(toolbar->imhtml);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
804 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
805 #endif
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
807 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
808 {
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
809 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
810 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
811 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
812
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
813 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
814 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
815
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
816 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
817 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
818 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
819
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
820 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
821 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
822 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
823 }
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
824
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
825 /* 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
826 * 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
827 * do the double toggling hack
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
828 */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
829 static void toggle_button_set_active_block(GtkToggleButton *button,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
830 gboolean is_active,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
831 GtkIMHtmlToolbar *toolbar)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
832 {
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
833 GObject *object;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
834 g_return_if_fail(toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
835
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
836 object = g_object_ref(button);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
837 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
838 0, 0, NULL, NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
839 gtk_toggle_button_set_active(button, is_active);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
840 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
841 0, 0, NULL, NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
842 g_object_unref(object);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
843 }
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
844
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
845 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
846 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
847 if (buttons & GTK_IMHTML_BOLD)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
848 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
849 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
850 toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
851
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
852 if (buttons & GTK_IMHTML_ITALIC)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
853 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
854 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
855 toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
856
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
857 if (buttons & GTK_IMHTML_UNDERLINE)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
858 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
859 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
860 toolbar);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
861 }
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
862
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
863 static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
864 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
865 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)))
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
866 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), FALSE,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
867 toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
868
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
869 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)))
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
870 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
871 FALSE, toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
872
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
873 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)))
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
874 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
875 FALSE, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
876 }
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
877
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
878 static void update_buttons(GtkIMHtmlToolbar *toolbar) {
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
879 gboolean bold, italic, underline;
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
880
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
881 bold = italic = underline = FALSE;
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
882 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml),
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
883 &bold, &italic, &underline);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
884
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
885 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
886 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
887 toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
888
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
889 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
890 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
891 toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
892
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
893 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
894 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
895 underline, toolbar);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
896 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
897
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
898 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) {
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
899 update_buttons(toolbar);
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
900 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
901
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
902 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location,
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
903 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar)
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
904 {
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
905 if(mark != gtk_text_buffer_get_insert(buffer))
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
906 return;
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
907
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
908 update_buttons(toolbar);
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
909 }
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
910
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 enum {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 LAST_SIGNAL
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 };
9863
0e3a84f18467 [gaim-migrate @ 10742]
Mark Doliner <mark@kingant.net>
parents: 9791
diff changeset
914 /* static guint signals [LAST_SIGNAL] = { 0 }; */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 gtk_imhtmltoolbar_finalize (GObject *object)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 {
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
919 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920
8685
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
921 if (toolbar->image_dialog != NULL)
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
922 {
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
923 gtk_widget_destroy(toolbar->image_dialog);
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
924 toolbar->image_dialog = NULL;
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
925 }
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
926
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
927 destroy_toolbar_font(NULL, NULL, toolbar);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
928 #if !GTK_CHECK_VERSION(2,4,0) /* Smiley selection menu */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
929 destroy_smiley_dialog(toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
930 #endif
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
931 destroy_toolbar_bgcolor(NULL, NULL, toolbar);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
932 destroy_toolbar_fgcolor(NULL, NULL, toolbar);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
933 close_link_dialog(toolbar);
8784
48dd097eb475 [gaim-migrate @ 9546]
Christian Hammond <chipx86@chipx86.com>
parents: 8756
diff changeset
934
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
935 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
936 free(toolbar->sml);
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
937 gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
939 G_OBJECT_CLASS(parent_class)->finalize (object);
8317
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
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 /* Boring GTK stuff */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class)
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 GtkObjectClass *object_class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 GObjectClass *gobject_class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 object_class = (GtkObjectClass*) class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 gobject_class = (GObjectClass*) class;
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
949 parent_class = gtk_type_class(GTK_TYPE_HBOX);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 gobject_class->finalize = gtk_imhtmltoolbar_finalize;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 {
10085
9c174a7f9afc [gaim-migrate @ 11096]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10080
diff changeset
955 GtkWidget *hbox = GTK_WIDGET(toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 GtkWidget *button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 GtkWidget *sep;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 GtkSizeGroup *sg;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 toolbar->imhtml = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 toolbar->font_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962 toolbar->fgcolor_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963 toolbar->bgcolor_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 toolbar->link_dialog = NULL;
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
965 toolbar->smiley_dialog = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 toolbar->image_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 toolbar->tooltips = gtk_tooltips_new();
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
969
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
970 gtk_box_set_spacing(GTK_BOX(toolbar), 6);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 /* Bold */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 G_CALLBACK(do_bold), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 toolbar->bold = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 /* Italic */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL);
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 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 G_CALLBACK(do_italic), toolbar);
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 toolbar->italic = button;
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 /* Underline */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 G_CALLBACK(do_underline), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 toolbar->underline = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 /* Increase font size */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 _("Larger font size"), NULL);
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 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 G_CALLBACK(do_big), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 toolbar->larger_size = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 /* Decrease font size */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 _("Smaller font size"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 G_CALLBACK(do_small), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 toolbar->smaller_size = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 /* Font Face */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 _("Font Face"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 G_CALLBACK(toggle_font), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 toolbar->font = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 /* Foreground Color */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 _("Foreground font color"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 G_CALLBACK(toggle_fg_color), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 toolbar->fgcolor = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 /* Background Color */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 _("Background color"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 G_CALLBACK(toggle_bg_color), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 toolbar->bgcolor = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 /* Insert Link */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 G_CALLBACK(insert_link_cb), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
1086
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 toolbar->link = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 /* Insert IM Image */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert image"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 G_CALLBACK(insert_image_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 toolbar->image = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 /* Insert Smiley */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
1106 g_signal_connect(G_OBJECT(button), "clicked",
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 G_CALLBACK(insert_smiley_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 toolbar->smiley = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1111 toolbar->sml = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112 gtk_widget_show_all(hbox);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 GtkWidget *gtk_imhtmltoolbar_new()
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 GType gtk_imhtmltoolbar_get_type()
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 static GType imhtmltoolbar_type = 0;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 if (!imhtmltoolbar_type) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125 static const GTypeInfo imhtmltoolbar_info = {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 sizeof(GtkIMHtmlToolbarClass),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 (GClassInitFunc) gtk_imhtmltoolbar_class_init,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 sizeof (GtkIMHtmlToolbar),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133 0,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 (GInstanceInitFunc) gtk_imhtmltoolbar_init
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 };
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
1137 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_HBOX,
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 return imhtmltoolbar_type;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
1145 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 {
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1147 GtkIMHtmlButtons buttons;
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1148 gboolean bold, italic, underline;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1149
8325
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1150 g_return_if_fail(toolbar != NULL);
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1151 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar));
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1152 g_return_if_fail(imhtml != NULL);
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1153 g_return_if_fail(GTK_IS_IMHTML(imhtml));
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1154
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155 toolbar->imhtml = imhtml;
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
1156 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
1157 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
1158 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
1159 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
1160 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
1161
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1162 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml));
8807
482fc53c969d [gaim-migrate @ 9569]
Mark Doliner <mark@kingant.net>
parents: 8788
diff changeset
1163 update_buttons_cb(GTK_IMHTML(imhtml), buttons, toolbar);
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1164
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1165 bold = italic = underline = FALSE;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1166
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
1167 gtk_imhtml_get_current_format(GTK_IMHTML(imhtml), &bold, &italic, &underline);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
1168
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1169 if(bold)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1170 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1171 toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
1172
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1173 if(italic)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1174 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1175 toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1176
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1177 if(underline)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1178 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1179 underline, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180 }
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1181
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1182 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1183 {
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1184 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1185 g_free(toolbar->sml);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
1186
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1187 toolbar->sml = g_strdup(proto_id);
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1188 }