annotate src/gtkimhtmltoolbar.c @ 13446:1118b6fc3206

[gaim-migrate @ 15821] Don't risk dereferencing a NULL pointer, nickname is guaranteed to be non-NULL if we got this far. Fixes CID 21 committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 07 Mar 2006 09:33:26 +0000
parents 12643ca39d59
children 60de8d24831d
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"
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11314
diff changeset
37 #include "gtkthemes.h"
9730
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
38 #include "gtkutils.h"
c9ac1976ef01 [gaim-migrate @ 10591]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
39
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
40 static GtkHBoxClass *parent_class = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
11275
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
42 static void toggle_button_set_active_block(GtkToggleButton *button,
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
43 gboolean is_active,
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
44 GtkIMHtmlToolbar *toolbar);
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
45
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
46
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 {
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
49 g_return_if_fail(toolbar != NULL);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 {
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
57 g_return_if_fail(toolbar != NULL);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 {
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
65 g_return_if_fail(toolbar != NULL);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 {
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
73 g_return_if_fail(toolbar != NULL);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
74 gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml));
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_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 g_return_if_fail(toolbar);
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
82 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
86 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
87 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
88 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 {
10135
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
90 if (widget != NULL)
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
91 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), "");
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
93 if (toolbar->font_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
94 {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 gtk_widget_destroy(toolbar->font_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 toolbar->font_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
100 static void
10125
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
101 realize_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
102 {
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
103 GtkFontSelection *sel;
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
104
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
105 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
106 gtk_widget_hide_all(gtk_widget_get_parent(sel->size_entry));
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
107 gtk_widget_show_all(sel->family_list);
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
108 gtk_widget_show(gtk_widget_get_parent(sel->family_list));
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
109 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
110 }
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
111
ee50e4797352 [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
112 static void
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
113 cancel_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
114 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
115 destroy_toolbar_font(widget, NULL, toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
116 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
117
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 static void apply_font(GtkWidget *widget, GtkFontSelection *fontsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 /* this could be expanded to include font size, weight, etc.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 but for now only works with font face */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 char *fontname;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 char *space;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 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
127
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 space = strrchr(fontname, ' ');
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 if(space && isdigit(*(space+1)))
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 *space = '\0';
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 g_free(fontname);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
135 cancel_toolbar_font(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 g_return_if_fail(toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
142
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
143 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font))) {
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
144 char *fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml));
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
145
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
146 if (!toolbar->font_dialog) {
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
147 toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
149 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
150
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
151 if(fontname) {
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
152 char *fonttif = g_strdup_printf("%s 12", fontname);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
153 g_free(fontname);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
154 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
155 fonttif);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
156 g_free(fonttif);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
157 } else {
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
158 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
159 DEFAULT_FONT_FACE);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
160 }
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
161
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
162 g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event",
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
163 G_CALLBACK(destroy_toolbar_font), toolbar);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
164 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->ok_button), "clicked",
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
165 G_CALLBACK(apply_font), toolbar->font_dialog);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
166 g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)->cancel_button), "clicked",
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
167 G_CALLBACK(cancel_toolbar_font), toolbar);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
168 g_signal_connect_after(G_OBJECT(toolbar->font_dialog), "realize",
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
169 G_CALLBACK(realize_toolbar_font), toolbar);
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
170 }
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 gtk_window_present(GTK_WINDOW(toolbar->font_dialog));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 } else {
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
173 cancel_toolbar_font(font, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
178 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
179 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
180 GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
181 {
10135
3855d3467437 [gaim-migrate @ 11202]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10134
diff changeset
182 if (widget != NULL)
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
183 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), "");
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
184
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
185 if (toolbar->fgcolor_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
186 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
187 gtk_widget_destroy(toolbar->fgcolor_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
188 toolbar->fgcolor_dialog = NULL;
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
189 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
190 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
191
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
192 static void cancel_toolbar_fgcolor(GtkWidget *widget,
8321
eb269b81fff8 [gaim-migrate @ 9045]
Christian Hammond <chipx86@chipx86.com>
parents: 8320
diff changeset
193 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
195 destroy_toolbar_fgcolor(widget, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 static void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 GdkColor text_color;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 char *open_tag;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 open_tag = g_malloc(30);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 gtk_color_selection_get_current_color(colorsel, &text_color);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 g_snprintf(open_tag, 23, "#%02X%02X%02X",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 text_color.red / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 text_color.green / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 text_color.blue / 256);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag);
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
211 g_free(open_tag);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
213 cancel_toolbar_fgcolor(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 toggle_fg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 GtkWidget *colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
221 GdkColor fgcolor;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
222 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
223
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 if (!toolbar->fgcolor_dialog) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
225
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog)->colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
228 if (color) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
229 gdk_color_parse(color, &fgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
230 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
231 g_free(color);
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
232 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
233
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
235
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
237 G_CALLBACK(destroy_toolbar_fgcolor), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
238 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
239 G_CALLBACK(do_fgcolor), colorsel);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
240 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
241 G_CALLBACK(cancel_toolbar_fgcolor), toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
243 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog));
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
244 } else {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
245 cancel_toolbar_fgcolor(color, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 gtk_widget_grab_focus(toolbar->imhtml);
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
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
250 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
251 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event,
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
252 GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 {
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
254 if (widget != NULL) {
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
255 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL))
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
256 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), "");
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
257 else
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
258 gtk_imhtml_toggle_background(GTK_IMHTML(toolbar->imhtml), "");
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
259 }
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
260
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
261 if (toolbar->bgcolor_dialog != NULL)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
262 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
263 gtk_widget_destroy(toolbar->bgcolor_dialog);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
264 toolbar->bgcolor_dialog = NULL;
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
265 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
266 }
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
267
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
268 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
269 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
270 {
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
271 destroy_toolbar_bgcolor(widget, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 GdkColor text_color;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "gaim_toolbar");
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 char *open_tag;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 open_tag = g_malloc(30);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 gtk_color_selection_get_current_color(colorsel, &text_color);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 g_snprintf(open_tag, 23, "#%02X%02X%02X",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 text_color.red / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 text_color.green / 256,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 text_color.blue / 256);
10777
ffa44a5159e0 [gaim-migrate @ 12392]
Sean Egan <seanegan@gmail.com>
parents: 10732
diff changeset
286 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL))
ffa44a5159e0 [gaim-migrate @ 12392]
Sean Egan <seanegan@gmail.com>
parents: 10732
diff changeset
287 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag);
ffa44a5159e0 [gaim-migrate @ 12392]
Sean Egan <seanegan@gmail.com>
parents: 10732
diff changeset
288 else
ffa44a5159e0 [gaim-migrate @ 12392]
Sean Egan <seanegan@gmail.com>
parents: 10732
diff changeset
289 gtk_imhtml_toggle_background(GTK_IMHTML(toolbar->imhtml), open_tag);
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
290 g_free(open_tag);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
292 cancel_toolbar_bgcolor(NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 GtkWidget *colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
300 GdkColor bgcolor;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10297
diff changeset
301 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
302
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 if (!toolbar->bgcolor_dialog) {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
304
8359
05c174138e94 [gaim-migrate @ 9083]
Mark Doliner <mark@kingant.net>
parents: 8325
diff changeset
305 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color"));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 colorsel = GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->colorsel;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
307 if (color) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
308 gdk_color_parse(color, &bgcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
309 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
310 g_free(color);
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
311 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
312
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 g_object_set_data(G_OBJECT(colorsel), "gaim_toolbar", toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
314
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event",
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
316 G_CALLBACK(destroy_toolbar_bgcolor), toolbar);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
317 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->ok_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
318 G_CALLBACK(do_bgcolor), colorsel);
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
319 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog)->cancel_button), "clicked",
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
320 G_CALLBACK(cancel_toolbar_bgcolor), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
321
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 }
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
323 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog));
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
324 } else {
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
325 cancel_toolbar_bgcolor(color, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 static void
11271
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
331 clear_formatting_cb(GtkWidget *clear, GtkIMHtmlToolbar *toolbar)
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
332 {
11275
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
333 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->clear), FALSE, toolbar);
11271
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
334 gtk_imhtml_clear_formatting(GTK_IMHTML(toolbar->imhtml));
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
335 }
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
336
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
337 static void
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 cancel_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 {
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
340 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
341
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 close_link_dialog(GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 if (toolbar->link_dialog != NULL)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 gaim_request_close(GAIM_REQUEST_FIELDS, toolbar->link_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 toolbar->link_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, GaimRequestFields *fields)
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 const char *url, *description;
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 url = gaim_request_fields_get_string(fields, "url");
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
361 if (GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC)
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
362 description = gaim_request_fields_get_string(fields, "description");
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
363 else
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
364 description = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 if (description == NULL)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 description = url;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
369 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
370 gtk_text_buffer_get_insert(GTK_IMHTML(toolbar->imhtml)->text_buffer),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
371 url, description);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
372
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
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 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 GaimRequestFields *fields;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 GaimRequestFieldGroup *group;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 GaimRequestField *field;
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
385 GtkTextIter start, end;
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
386 char *msg;
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
387 char *desc = NULL;
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
388
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 fields = gaim_request_fields_new();
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
390
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 group = gaim_request_field_group_new(NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 gaim_request_fields_add_group(fields, group);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
393
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 gaim_request_field_set_required(field, TRUE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 gaim_request_field_group_add_field(group, field);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
397
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
398 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) {
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
399 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
400 desc = gtk_imhtml_get_text(GTK_IMHTML(toolbar->imhtml), &start, &end);
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
401 }
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
402 field = gaim_request_field_string_new("description", _("_Description"),
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
403 desc, FALSE);
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
404 gaim_request_field_group_add_field(group, field);
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
405 msg = g_strdup(_("Please enter the URL and description of the "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
406 "link that you want to insert. The description "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
407 "is optional."));
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
408 } else {
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
409 msg = g_strdup(_("Please enter the URL of the "
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
410 "link that you want to insert."));
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
411 }
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 toolbar->link_dialog =
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 gaim_request_fields(toolbar, _("Insert Link"),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 NULL,
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
416 msg,
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 fields,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 _("_Insert"), G_CALLBACK(do_insert_link_cb),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 _("Cancel"), G_CALLBACK(cancel_link_cb),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 toolbar);
9041
812e7aa7eafa [gaim-migrate @ 9817]
Tim Ringenbach <marv@pidgin.im>
parents: 9027
diff changeset
421 g_free(msg);
9599
a1029432ae4a [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
422 g_free(desc);
8322
ffb601c6b833 [gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents: 8321
diff changeset
423 } else {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 close_link_dialog(toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 static void
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
431 do_insert_image_cb(GtkWidget *widget, int response, GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 {
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
433 gchar *filename, *name, *buf;
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
434 char *filedata;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 size_t size;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 GError *error = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 int id;
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
438 GtkTextIter iter;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
439 GtkTextMark *ins;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
441 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
442 if (response != GTK_RESPONSE_ACCEPT) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
443 #else /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
444 if (response != GTK_RESPONSE_OK) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
445 #endif /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
450 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
451 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
452 #else /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
453 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
454 #endif /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
456 if (filename == NULL) {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
461 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
462 if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(widget))) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
463 g_free(filename);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
464 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
465 return;
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
466 }
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
467 #endif /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
468
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
469 /* The following triggers a callback that closes the widget */
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
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
472 if (!g_file_get_contents(filename, &filedata, &size, &error)) {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 gaim_notify_error(NULL, NULL, error->message, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 g_error_free(error);
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
476 g_free(filename);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
481 name = strrchr(filename, G_DIR_SEPARATOR) + 1;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
483 id = gaim_imgstore_add(filedata, size, name);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 g_free(filedata);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
486 if (id == 0) {
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
487 buf = g_strdup_printf(_("Failed to store image: %s\n"), filename);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 gaim_notify_error(NULL, NULL, buf, NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 g_free(buf);
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
491 g_free(filename);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 return;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
496 g_free(filename);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
497
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
498 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
499 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
500 &iter, ins);
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
501 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
502 gaim_imgstore_unref(id);
8317
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
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 GtkWidget *window;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 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
512 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
513 window = gtk_file_chooser_dialog_new(_("Insert Image"),
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
514 NULL,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
515 GTK_FILE_CHOOSER_ACTION_OPEN,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
516 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
517 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
518 NULL);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
519 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_ACCEPT);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
520 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(window)),
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
521 "response", G_CALLBACK(do_insert_image_cb), toolbar);
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
522 #else /* FILECHOOSER */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 window = gtk_file_selection_new(_("Insert Image"));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_OK);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 "response", G_CALLBACK(do_insert_image_cb), toolbar);
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
527 #endif /* FILECHOOSER */
8317
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 gtk_widget_show(window);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 toolbar->image_dialog = window;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 } else {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 gtk_widget_destroy(toolbar->image_dialog);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 toolbar->image_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 }
9522
4399fc6e667a [gaim-migrate @ 10349]
Mark Doliner <mark@kingant.net>
parents: 9287
diff changeset
535
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 gtk_widget_grab_focus(toolbar->imhtml);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
539
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
540 static void
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
541 destroy_smiley_dialog(GtkIMHtmlToolbar *toolbar)
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
542 {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
543 if (toolbar->smiley_dialog != NULL)
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
544 {
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
545 gtk_widget_destroy(toolbar->smiley_dialog);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
546 toolbar->smiley_dialog = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
550 static void
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
551 close_smiley_dialog(GtkWidget *widget, GdkEvent *event,
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
552 GtkIMHtmlToolbar *toolbar)
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
553 {
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
554 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
555 }
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
556
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
558 static void
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
559 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 {
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
561 char *smiley_text, *escaped_smiley;
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
562
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
563 smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text");
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10504
diff changeset
564 escaped_smiley = g_markup_escape_text(smiley_text, -1);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8447
diff changeset
566 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml),
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8447
diff changeset
567 GTK_IMHTML(toolbar->imhtml)->protocol_name,
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
568 escaped_smiley);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569
9027
1bd8bda384e7 [gaim-migrate @ 9803]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
570 g_free(escaped_smiley);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
571
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
572 close_smiley_dialog(NULL, NULL, toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
575 /* smiley buttons list */
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
576 struct smiley_button_list {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
577 int width, height;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
578 GtkWidget *button;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
579 struct smiley_button_list *next;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
580 };
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581
11862
f8cd06753755 [gaim-migrate @ 14153]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11849
diff changeset
582 static struct smiley_button_list *
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
583 sort_smileys(struct smiley_button_list *ls, GtkIMHtmlToolbar *toolbar, int *width, char *filename, char *face)
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
584 {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
585 GtkWidget *image;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
586 GtkWidget *button;
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
587 GtkRequisition size;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
588 struct smiley_button_list *cur;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
589 struct smiley_button_list *it, *it_last;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
591 cur = malloc(sizeof(struct smiley_button_list));
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
592 it = ls;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
593 it_last = ls; /* list iterators*/
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
594 image = gtk_image_new_from_file(filename);
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
595
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
596 gtk_widget_size_request(image, &size);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
597 (*width) += size.width;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
598
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
599 button = gtk_button_new();
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
600 gtk_container_add(GTK_CONTAINER(button), image);
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
601
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
602 g_object_set_data(G_OBJECT(button), "smiley_text", face);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
603 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
604
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
605 gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
606
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
607 /* these look really weird with borders */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
608 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
609
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
610 /* set current element to add */
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
611 cur->height = size.height;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
612 cur->width = size.width;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
613 cur->button = button;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
614 cur->next = ls;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
615
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
616 /* check where to insert by height */
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
617 if (ls == NULL)
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
618 return cur;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
619 while (it != NULL) {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
620 it_last = it;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
621 it = it->next;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
622 }
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
623 cur->next = it;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
624 it_last->next = cur;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
625 return ls;
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
626 }
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
627
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
628
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
629 static gboolean
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
630 smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley)
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
631 {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
632 while (list) {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 GtkIMHtmlSmiley *cur = list->data;
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
634 if (!strcmp(cur->file, smiley->file))
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 return FALSE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 list = list->next;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
642 static void
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
643 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar)
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
644 {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
645 GtkWidget *dialog;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
646 GtkWidget *smiley_table = NULL;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
647 GSList *smileys, *unique_smileys = NULL;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
648
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
649 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
650 destroy_smiley_dialog(toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
651 gtk_widget_grab_focus(toolbar->imhtml);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
652 return;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
653 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
654
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
655 if (toolbar->sml)
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11314
diff changeset
656 smileys = gaim_gtkthemes_get_proto_smileys(toolbar->sml);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
657 else
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11314
diff changeset
658 smileys = gaim_gtkthemes_get_proto_smileys(NULL);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
659
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
660 while(smileys) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
661 GtkIMHtmlSmiley *smiley = smileys->data;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
662 if(!smiley->hidden) {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
663 if(smiley_is_unique(unique_smileys, smiley))
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
664 unique_smileys = g_slist_append(unique_smileys, smiley);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
665 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
666 smileys = smileys->next;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
667 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
668
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
669 GAIM_DIALOG(dialog);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
670
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
671 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
672 gtk_window_set_role(GTK_WINDOW(dialog), "smiley_dialog");
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
673 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
674
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
675 if (g_slist_length(unique_smileys)) {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
676 struct smiley_button_list *ls, *it, *it_tmp;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
677 GtkWidget *line;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
678 int line_width = 0;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
679 int max_line_width, num_lines;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
680 int col=0;
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
681
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
682 /* We use hboxes packed in a vbox */
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
683 ls = NULL;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
684 line = gtk_hbox_new(FALSE, 0);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
685 line_width = 0;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
686 max_line_width = 0;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
687 num_lines = floor(sqrt(g_slist_length(unique_smileys)));
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
688 smiley_table = gtk_vbox_new(FALSE, 0);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
689
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
690 /* create list of smileys sorted by height */
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
691 while (unique_smileys) {
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
692 GtkIMHtmlSmiley *smiley = unique_smileys->data;
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
693 if (!smiley->hidden) {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
694 fflush(stdout);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
695 ls = sort_smileys(ls, toolbar, &max_line_width, smiley->file, smiley->smile);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
696 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
697 unique_smileys = unique_smileys->next;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
698 }
10894
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
699 /* pack buttons of the list */
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
700 max_line_width = max_line_width / num_lines;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
701 it = ls;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
702 while (it != NULL)
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
703 {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
704 it_tmp = it;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
705 gtk_box_pack_start(GTK_BOX(line), it->button, TRUE, TRUE, 0);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
706 gtk_widget_show(it->button);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
707 line_width += it->width;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
708 if (line_width >= max_line_width) {
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
709 gtk_box_pack_start(GTK_BOX(smiley_table), line, FALSE, TRUE, 0);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
710 line = gtk_hbox_new(FALSE, 0);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
711 line_width = 0;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
712 col = 0;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
713 }
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
714 col++;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
715 it = it->next;
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
716 free(it_tmp);
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
717 }
1a0e699521c3 [gaim-migrate @ 12608]
Mark Doliner <mark@kingant.net>
parents: 10814
diff changeset
718 gtk_box_pack_start(GTK_BOX(smiley_table), line, FALSE, TRUE, 0);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
719 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
720 else {
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
721 smiley_table = gtk_label_new(_("This theme has no available smileys."));
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
722 }
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
723
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
724 gtk_container_add(GTK_CONTAINER(dialog), smiley_table);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
725
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
726 gtk_widget_show(smiley_table);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
727
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
728 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
729
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
730 /* connect signals */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
731 g_signal_connect(G_OBJECT(dialog), "delete_event",
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
732 G_CALLBACK(close_smiley_dialog), toolbar);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
733
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
734 /* show everything */
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
735 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!"));
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
736 gtk_widget_show_all(dialog);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
737
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
738 toolbar->smiley_dialog = dialog;
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
739
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
740 gtk_widget_grab_focus(toolbar->imhtml);
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
741 }
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
743 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
744 {
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
745 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
746 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
747 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
748
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
749 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
750 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
751
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
752 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
753 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
754 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
755
11314
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
756 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->clear),
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
757 (buttons & GTK_IMHTML_BOLD ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
758 buttons & GTK_IMHTML_ITALIC ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
759 buttons & GTK_IMHTML_UNDERLINE ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
760 buttons & GTK_IMHTML_GROW ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
761 buttons & GTK_IMHTML_SHRINK ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
762 buttons & GTK_IMHTML_FACE ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
763 buttons & GTK_IMHTML_FORECOLOR ||
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
764 buttons & GTK_IMHTML_BACKCOLOR));
bcc7f30c91bd [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
765
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
766 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
767 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
768 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
769 }
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
770
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
771 /* 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
772 * 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
773 * do the double toggling hack
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
774 */
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
775 static void toggle_button_set_active_block(GtkToggleButton *button,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
776 gboolean is_active,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
777 GtkIMHtmlToolbar *toolbar)
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
778 {
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
779 GObject *object;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
780 g_return_if_fail(toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
781
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
782 object = g_object_ref(button);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
783 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
784 0, 0, NULL, NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
785 gtk_toggle_button_set_active(button, is_active);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
786 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
787 0, 0, NULL, NULL, toolbar);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
788 g_object_unref(object);
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
789 }
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8391
diff changeset
790
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
791 static void update_buttons(GtkIMHtmlToolbar *toolbar) {
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
792 gboolean bold, italic, underline;
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
793 char *tmp;
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
794 char *tmp2;
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
795
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
796 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml),
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
797 &bold, &italic, &underline);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
798
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
799 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
800 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
801 toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
802
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
803 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
804 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
805 toolbar);
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
806
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
807 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
808 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8516
diff changeset
809 underline, toolbar);
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
810
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
811 /* These buttons aren't ever "active". */
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
812 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
813 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
814
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
815 tmp = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml));
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
816 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->font),
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
817 (tmp != NULL), toolbar);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
818 g_free(tmp);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
819
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
820 tmp = gtk_imhtml_get_current_forecolor(GTK_IMHTML(toolbar->imhtml));
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
821 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->fgcolor),
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
822 (tmp != NULL), toolbar);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
823 g_free(tmp);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
824
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
825 tmp = gtk_imhtml_get_current_backcolor(GTK_IMHTML(toolbar->imhtml));
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
826 tmp2 = gtk_imhtml_get_current_background(GTK_IMHTML(toolbar->imhtml));
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
827 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bgcolor),
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
828 (tmp != NULL || tmp2 != NULL), toolbar);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
829 g_free(tmp);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
830 g_free(tmp2);
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
831 }
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
832
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
833 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
834 {
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
835 update_buttons(toolbar);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
836 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
837
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
838 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) {
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
839 update_buttons(toolbar);
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
840 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
841
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
842 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location,
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
843 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar)
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
844 {
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
845 if(mark != gtk_text_buffer_get_insert(buffer))
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
846 return;
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
847
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
848 update_buttons(toolbar);
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
849 }
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
850
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 enum {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 LAST_SIGNAL
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 };
9863
0e3a84f18467 [gaim-migrate @ 10742]
Mark Doliner <mark@kingant.net>
parents: 9791
diff changeset
854 /* static guint signals [LAST_SIGNAL] = { 0 }; */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 static void
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 gtk_imhtmltoolbar_finalize (GObject *object)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 {
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
859 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860
8685
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
861 if (toolbar->image_dialog != NULL)
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
862 {
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
863 gtk_widget_destroy(toolbar->image_dialog);
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
864 toolbar->image_dialog = NULL;
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
865 }
2ac2f4cf1de5 [gaim-migrate @ 9438]
Christian Hammond <chipx86@chipx86.com>
parents: 8677
diff changeset
866
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
867 destroy_toolbar_font(NULL, NULL, toolbar);
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
868 destroy_smiley_dialog(toolbar);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
869 destroy_toolbar_bgcolor(NULL, NULL, toolbar);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
870 destroy_toolbar_fgcolor(NULL, NULL, toolbar);
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
871 close_link_dialog(toolbar);
12904
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
872 if (toolbar->imhtml) {
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
873 g_signal_handlers_disconnect_matched(toolbar->imhtml,
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
874 G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
875 toolbar);
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
876 g_signal_handlers_disconnect_matched(GTK_IMHTML(toolbar->imhtml)->text_buffer,
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
877 G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
878 toolbar);
12643ca39d59 [gaim-migrate @ 15257]
Richard Laager <rlaager@wiktel.com>
parents: 12900
diff changeset
879 }
8784
48dd097eb475 [gaim-migrate @ 9546]
Christian Hammond <chipx86@chipx86.com>
parents: 8756
diff changeset
880
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
881 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
882 free(toolbar->sml);
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
883 gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884
8391
45d1e3ed5a86 [gaim-migrate @ 9120]
Mark Doliner <mark@kingant.net>
parents: 8380
diff changeset
885 G_OBJECT_CLASS(parent_class)->finalize (object);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10777
diff changeset
888 /* Boring GTK+ stuff */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 GtkObjectClass *object_class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 GObjectClass *gobject_class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 object_class = (GtkObjectClass*) class;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 gobject_class = (GObjectClass*) class;
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
895 parent_class = gtk_type_class(GTK_TYPE_HBOX);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 gobject_class->finalize = gtk_imhtmltoolbar_finalize;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar)
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 {
10085
9c174a7f9afc [gaim-migrate @ 11096]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10080
diff changeset
901 GtkWidget *hbox = GTK_WIDGET(toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 GtkWidget *button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903 GtkWidget *sep;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 GtkSizeGroup *sg;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 toolbar->imhtml = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 toolbar->font_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 toolbar->fgcolor_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 toolbar->bgcolor_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 toolbar->link_dialog = NULL;
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
911 toolbar->smiley_dialog = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 toolbar->image_dialog = NULL;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 toolbar->tooltips = gtk_tooltips_new();
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
915
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10894
diff changeset
916 gtk_box_set_spacing(GTK_BOX(toolbar), GAIM_HIG_BOX_SPACE);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 /* Bold */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Bold"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 G_CALLBACK(do_bold), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 toolbar->bold = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 /* Italic */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Italic"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 G_CALLBACK(do_italic), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 toolbar->italic = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 /* Underline */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Underline"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 G_CALLBACK(do_underline), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 toolbar->underline = button;
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 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 /* Increase font size */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 _("Larger font size"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 G_CALLBACK(do_big), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 toolbar->larger_size = button;
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 /* Decrease font size */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 _("Smaller font size"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 G_CALLBACK(do_small), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 toolbar->smaller_size = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
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 /* Font Face */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 _("Font Face"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 G_CALLBACK(toggle_font), toolbar);
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 toolbar->font = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 /* Foreground Color */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 _("Foreground font color"), NULL);
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 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 G_CALLBACK(toggle_fg_color), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 toolbar->fgcolor = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 /* Background Color */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 gtk_tooltips_set_tip(toolbar->tooltips, button,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 _("Background color"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017 G_CALLBACK(toggle_bg_color), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 toolbar->bgcolor = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 /* Sep */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 sep = gtk_vseparator_new();
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024
11271
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1025 /* Clear Formatting */
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1026 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_CLEAR);
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1027 gtk_size_group_add_widget(sg, button);
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1028 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1029 gtk_tooltips_set_tip(toolbar->tooltips, button,
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1030 _("Clear formatting"), NULL);
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1031
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1032 g_signal_connect(G_OBJECT(button), "clicked",
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1033 G_CALLBACK(clear_formatting_cb), toolbar);
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1034
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1035 toolbar->clear = button;
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1036
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1037 /* Sep */
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1038 sep = gtk_vseparator_new();
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1039 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
b33eccbc3a10 [gaim-migrate @ 13454]
Richard Laager <rlaager@wiktel.com>
parents: 11267
diff changeset
1040
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 /* Insert Link */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert link"), NULL);
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(insert_link_cb), toolbar);
8319
a2c5537a814b [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
1048
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 toolbar->link = 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 /* Insert IM Image */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE);
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, _("Insert image"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 g_signal_connect(G_OBJECT(button), "clicked",
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 G_CALLBACK(insert_image_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 toolbar->image = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 /* Insert Smiley */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 gtk_size_group_add_widget(sg, button);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 gtk_tooltips_set_tip(toolbar->tooltips, button, _("Insert smiley"), NULL);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067
10138
5fb5c447eb4f [gaim-migrate @ 11208]
Mark Doliner <mark@kingant.net>
parents: 10135
diff changeset
1068 g_signal_connect(G_OBJECT(button), "clicked",
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 G_CALLBACK(insert_smiley_cb), toolbar);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 toolbar->smiley = button;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1073 toolbar->sml = NULL;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 gtk_widget_show_all(hbox);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 GtkWidget *gtk_imhtmltoolbar_new()
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 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL));
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 GType gtk_imhtmltoolbar_get_type()
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 static GType imhtmltoolbar_type = 0;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 if (!imhtmltoolbar_type) {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 static const GTypeInfo imhtmltoolbar_info = {
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088 sizeof(GtkIMHtmlToolbarClass),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 (GClassInitFunc) gtk_imhtmltoolbar_class_init,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 NULL,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 sizeof (GtkIMHtmlToolbar),
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 0,
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 11862
diff changeset
1096 (GInstanceInitFunc) gtk_imhtmltoolbar_init,
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 11862
diff changeset
1097 NULL
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 };
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099
10080
8e6329b8dcc1 [gaim-migrate @ 11062]
Sean Egan <seanegan@gmail.com>
parents: 9971
diff changeset
1100 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_HBOX,
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0);
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 return imhtmltoolbar_type;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 }
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107
8324
2df8b01af581 [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
1108 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml)
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 {
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1110 GtkIMHtmlButtons buttons;
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1111 gboolean bold, italic, underline;
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8456
diff changeset
1112
8325
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1113 g_return_if_fail(toolbar != NULL);
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1114 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar));
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1115 g_return_if_fail(imhtml != NULL);
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1116 g_return_if_fail(GTK_IS_IMHTML(imhtml));
415283e39bce [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1117
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 toolbar->imhtml = imhtml;
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
1119 g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar);
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
1120 g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar);
11275
ffc86d9ad8b7 [gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents: 11271
diff changeset
1121 g_signal_connect_after(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(update_format_cb), toolbar);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8481
diff changeset
1122 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
1123 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
1124
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1125 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml));
8807
482fc53c969d [gaim-migrate @ 9569]
Mark Doliner <mark@kingant.net>
parents: 8788
diff changeset
1126 update_buttons_cb(GTK_IMHTML(imhtml), buttons, toolbar);
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8785
diff changeset
1127
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8506
diff changeset
1128 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
1129
11267
477e5cca8287 [gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents: 11243
diff changeset
1130 update_buttons(toolbar);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 }
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1132
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1133 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1134 {
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1135 if (toolbar->sml)
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1136 g_free(toolbar->sml);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 10125
diff changeset
1137
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1138 toolbar->sml = g_strdup(proto_id);
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
1139 }