pidgin/gtkimhtmltoolbar.c

Wed, 01 Jan 2014 10:57:45 +0530

author
Ankit Vani <a@nevitus.org>
date
Wed, 01 Jan 2014 10:57:45 +0530
changeset 35126
669cb2286130
parent 34955
854143116575
child 36968
21b1fc18a521
permissions
-rw-r--r--

Remove "'fontdesc' attribute not allowed in <span>" warnings
gtk_label_set_markup_with_mnemonic parses _ as a mnemonic in font_desc, and escaping with another _ doesn't work as pango docs suggest.
However, face should work fine as we are only using the font name.

8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1 /*
10297
b36800725b7a [gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents: 10138
diff changeset
2 * @file gtkimhtmltoolbar.c GTK+ IMHtml Toolbar
16254
eeb2bba4dc94 Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents: 15931
diff changeset
3 * @ingroup pidgin
20330
650a7af9c238 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents: 20328
diff changeset
4 */
650a7af9c238 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents: 20328
diff changeset
5
650a7af9c238 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents: 20328
diff changeset
6 /* pidgin
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
7 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
10 * source distribution.
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
11 *
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
13 * under the terms of the GNU General Public License as published by
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
16 *
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
21 *
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19761
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
25 *
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
26 */
9791
f5c5bda0b96b [gaim-migrate @ 10659]
Gary Kramlich <grim@pidgin.im>
parents: 9730
diff changeset
27 #include "internal.h"
15577
b8129373f65e More pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15571
diff changeset
28 #include "pidgin.h"
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
29
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
30 #include "imgstore.h"
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
31 #include "notify.h"
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
32 #include "prefs.h"
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
33 #include "request.h"
15883
969b74a3e27a According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
34 #include "pidginstock.h"
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
35 #include "util.h"
25922
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
36 #include "debug.h"
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
37
9730
e59812364b8b [gaim-migrate @ 10591]
Mark Doliner <markdoliner@pidgin.im>
parents: 9709
diff changeset
38 #include "gtkdialogs.h"
e59812364b8b [gaim-migrate @ 10591]
Mark Doliner <markdoliner@pidgin.im>
parents: 9709
diff changeset
39 #include "gtkimhtmltoolbar.h"
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
40 #include "gtksmiley.h"
11525
1d06283bdcc9 [gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents: 11314
diff changeset
41 #include "gtkthemes.h"
9730
e59812364b8b [gaim-migrate @ 10591]
Mark Doliner <markdoliner@pidgin.im>
parents: 9709
diff changeset
42 #include "gtkutils.h"
e59812364b8b [gaim-migrate @ 10591]
Mark Doliner <markdoliner@pidgin.im>
parents: 9709
diff changeset
43
17394
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
44 #include <gdk/gdkkeysyms.h>
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
45
33177
d5af963e67c9 Fix toolbar tooltips compile.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33170
diff changeset
46 #define GTK_TOOLTIPS_VAR toolbar->tooltips
33170
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33158
diff changeset
47 #include "gtk3compat.h"
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33158
diff changeset
48
10080
d562573fff16 [gaim-migrate @ 11062]
Sean Egan <seanegan@pidgin.im>
parents: 9971
diff changeset
49 static GtkHBoxClass *parent_class = NULL;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
50
11275
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
51 static void toggle_button_set_active_block(GtkToggleButton *button,
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
52 gboolean is_active,
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
53 GtkIMHtmlToolbar *toolbar);
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
54
30408
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
55 static gboolean
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
56 gtk_imhtmltoolbar_popup_menu(GtkWidget *widget,
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
57 GdkEventButton *event, GtkIMHtmlToolbar *toolbar);
11275
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
58
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
59 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
60 {
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
61 g_return_if_fail(toolbar != NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
62 gtk_imhtml_toggle_bold(GTK_IMHTML(toolbar->imhtml));
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
63 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
64 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
65
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
66 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
67 do_italic(GtkWidget *italic, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
68 {
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
69 g_return_if_fail(toolbar != NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
70 gtk_imhtml_toggle_italic(GTK_IMHTML(toolbar->imhtml));
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
71 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
72 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
73
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
74 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
75 do_underline(GtkWidget *underline, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
76 {
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
77 g_return_if_fail(toolbar != NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
78 gtk_imhtml_toggle_underline(GTK_IMHTML(toolbar->imhtml));
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
79 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
80 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
81
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
82 static void
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
83 do_strikethrough(GtkWidget *strikethrough, GtkIMHtmlToolbar *toolbar)
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
84 {
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
85 g_return_if_fail(toolbar != NULL);
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
86 gtk_imhtml_toggle_strike(GTK_IMHTML(toolbar->imhtml));
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
87 gtk_widget_grab_focus(toolbar->imhtml);
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
88 }
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
89
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
90 static void
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
91 do_small(GtkWidget *smalltb, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
92 {
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
93 g_return_if_fail(toolbar != NULL);
17403
b0e8707193b5 Only change the size when the imhtmltoolbar button has been activated,
Kevin Stange <kstange@pidgin.im>
parents: 17303
diff changeset
94 /* Only shrink the font on activation, not deactivation as well */
b0e8707193b5 Only change the size when the imhtmltoolbar button has been activated,
Kevin Stange <kstange@pidgin.im>
parents: 17303
diff changeset
95 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smalltb)))
b0e8707193b5 Only change the size when the imhtmltoolbar button has been activated,
Kevin Stange <kstange@pidgin.im>
parents: 17303
diff changeset
96 gtk_imhtml_font_shrink(GTK_IMHTML(toolbar->imhtml));
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
97 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
98 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
99
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
100 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
101 do_big(GtkWidget *large, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
102 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
103 g_return_if_fail(toolbar);
17403
b0e8707193b5 Only change the size when the imhtmltoolbar button has been activated,
Kevin Stange <kstange@pidgin.im>
parents: 17303
diff changeset
104 /* Only grow the font on activation, not deactivation as well */
b0e8707193b5 Only change the size when the imhtmltoolbar button has been activated,
Kevin Stange <kstange@pidgin.im>
parents: 17303
diff changeset
105 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(large)))
b0e8707193b5 Only change the size when the imhtmltoolbar button has been activated,
Kevin Stange <kstange@pidgin.im>
parents: 17303
diff changeset
106 gtk_imhtml_font_grow(GTK_IMHTML(toolbar->imhtml));
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
107 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
108 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
109
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
110 static gboolean
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
111 destroy_toolbar_font(GtkWidget *widget, GdkEvent *event,
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
112 GtkIMHtmlToolbar *toolbar)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
113 {
10135
760803be53d2 [gaim-migrate @ 11202]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10134
diff changeset
114 if (widget != NULL)
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
115 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), "");
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
116
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
117 if (toolbar->font_dialog != NULL)
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
118 {
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
119 gtk_widget_destroy(toolbar->font_dialog);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
120 toolbar->font_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
121 }
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
122 return FALSE;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
123 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
124
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
125 static void
10125
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
126 realize_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
127 {
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
128 GtkFontSelection *sel;
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
129
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
130 sel = GTK_FONT_SELECTION(
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
131 gtk_font_selection_dialog_get_font_selection(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog)));
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
132 gtk_widget_hide(gtk_widget_get_parent(
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
133 gtk_font_selection_get_size_entry(sel)));
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
134 gtk_widget_show_all(gtk_font_selection_get_family_list(sel));
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
135 gtk_widget_show(gtk_widget_get_parent(
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
136 gtk_font_selection_get_family_list(sel)));
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
137 gtk_widget_show(gtk_widget_get_parent(gtk_widget_get_parent(
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
138 gtk_font_selection_get_family_list(sel))));
10125
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
139 }
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
140
dc406c15aceb [gaim-migrate @ 11162]
Tim Ringenbach <marv@pidgin.im>
parents: 10085
diff changeset
141 static void
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
142 cancel_toolbar_font(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
143 {
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
144 destroy_toolbar_font(widget, NULL, toolbar);
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
145 }
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
146
28257
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
147 static void
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
148 apply_font(GtkWidget *widget, GtkFontSelectionDialog *fontsel)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
149 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
150 /* this could be expanded to include font size, weight, etc.
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
151 but for now only works with font face */
28257
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
152 gchar *fontname = gtk_font_selection_dialog_get_font_name(fontsel);
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
153 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel),
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
154 "purple_toolbar");
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
155
28257
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
156 if (fontname) {
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
157 const gchar *family_name = NULL;
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
158 PangoFontDescription *desc = NULL;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
159
28257
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
160 desc = pango_font_description_from_string(fontname);
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
161 family_name = pango_font_description_get_family(desc);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
162
28257
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
163 if (family_name) {
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
164 gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml),
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
165 family_name);
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
166 }
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
167
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
168 pango_font_description_free(desc);
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
169 g_free(fontname);
60cee5b2d42e Fix apply_font to use a PangoFontDescription to get the requested font family
Etan Reisner <deryni@pidgin.im>
parents: 26828
diff changeset
170 }
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
171
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
172 cancel_toolbar_font(NULL, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
173 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
174
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
175 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
176 toggle_font(GtkWidget *font, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
177 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
178 g_return_if_fail(toolbar);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
179
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
180 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font))) {
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
181 char *fontname = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml));
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
182
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
183 if (!toolbar->font_dialog) {
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
184 toolbar->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
185
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
186 g_object_set_data(G_OBJECT(toolbar->font_dialog), "purple_toolbar", toolbar);
10134
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
187
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
188 if(fontname) {
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
189 char *fonttif = g_strdup_printf("%s 12", fontname);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
190 g_free(fontname);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
191 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
192 fonttif);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
193 g_free(fonttif);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
194 } else {
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
195 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog),
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
196 DEFAULT_FONT_FACE);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
197 }
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
198
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
199 g_signal_connect(G_OBJECT(toolbar->font_dialog), "delete_event",
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
200 G_CALLBACK(destroy_toolbar_font), toolbar);
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
201 g_signal_connect(G_OBJECT(
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
202 gtk_font_selection_dialog_get_ok_button(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog))),
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
203 "clicked", G_CALLBACK(apply_font), toolbar->font_dialog);
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
204 g_signal_connect(G_OBJECT(
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
205 gtk_font_selection_dialog_get_cancel_button(GTK_FONT_SELECTION_DIALOG(toolbar->font_dialog))),
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
206 "clicked", G_CALLBACK(cancel_toolbar_font), toolbar);
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
207 g_signal_connect_after(G_OBJECT(toolbar->font_dialog), "realize",
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
208 G_CALLBACK(realize_toolbar_font), toolbar);
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
209 }
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
210 gtk_window_present(GTK_WINDOW(toolbar->font_dialog));
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
211 } else {
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
212 cancel_toolbar_font(font, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
213 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
214 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
215 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
216
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
217 static gboolean
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
218 destroy_toolbar_fgcolor(GtkWidget *widget, GdkEvent *event,
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
219 GtkIMHtmlToolbar *toolbar)
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
220 {
10135
760803be53d2 [gaim-migrate @ 11202]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10134
diff changeset
221 if (widget != NULL)
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
222 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), "");
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
223
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
224 if (toolbar->fgcolor_dialog != NULL)
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
225 {
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
226 gtk_widget_destroy(toolbar->fgcolor_dialog);
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
227 toolbar->fgcolor_dialog = NULL;
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
228 }
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
229 return FALSE;
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
230 }
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
231
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
232 static void cancel_toolbar_fgcolor(GtkWidget *widget,
8321
477316d4d8a3 [gaim-migrate @ 9045]
Christian Hammond <chipx86@chipx86.com>
parents: 8320
diff changeset
233 GtkIMHtmlToolbar *toolbar)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
234 {
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
235 destroy_toolbar_fgcolor(widget, NULL, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
236 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
237
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
238 static void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
239 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
240 GdkColor text_color;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
241 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "purple_toolbar");
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
242 char *open_tag;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
243
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
244 open_tag = g_malloc(30);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
245 gtk_color_selection_get_current_color(colorsel, &text_color);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
246 g_snprintf(open_tag, 23, "#%02X%02X%02X",
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
247 text_color.red / 256,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
248 text_color.green / 256,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
249 text_color.blue / 256);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
250 gtk_imhtml_toggle_forecolor(GTK_IMHTML(toolbar->imhtml), open_tag);
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
251 g_free(open_tag);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
252
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
253 cancel_toolbar_fgcolor(NULL, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
254 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
255
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
256 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
257 toggle_fg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
258 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
259 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
260 GtkWidget *colorsel;
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
261 GdkColor fgcolor;
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10297
diff changeset
262 char *color = gtk_imhtml_get_current_forecolor(GTK_IMHTML(toolbar->imhtml));
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
263
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
264 if (!toolbar->fgcolor_dialog) {
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
265 GtkWidget *ok_button;
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
266 GtkWidget *cancel_button;
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
267
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
268 toolbar->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
269 colorsel =
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
270 gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(toolbar->fgcolor_dialog));
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
271 if (color) {
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
272 gdk_color_parse(color, &fgcolor);
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
273 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor);
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10297
diff changeset
274 g_free(color);
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
275 }
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
276
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
277 g_object_set_data(G_OBJECT(colorsel), "purple_toolbar", toolbar);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
278
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
279 g_object_get(G_OBJECT(toolbar->fgcolor_dialog), "ok-button", &ok_button, NULL);
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
280 g_object_get(G_OBJECT(toolbar->fgcolor_dialog), "cancel-button", &cancel_button, NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
281 g_signal_connect(G_OBJECT(toolbar->fgcolor_dialog), "delete_event",
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
282 G_CALLBACK(destroy_toolbar_fgcolor), toolbar);
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
283 g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(do_fgcolor), colorsel);
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
284 g_signal_connect(G_OBJECT(cancel_button), "clicked",
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
285 G_CALLBACK(cancel_toolbar_fgcolor), toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
286 }
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
287 gtk_window_present(GTK_WINDOW(toolbar->fgcolor_dialog));
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
288 } else {
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
289 cancel_toolbar_fgcolor(color, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
290 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
291 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
292 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
293
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
294 static gboolean
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
295 destroy_toolbar_bgcolor(GtkWidget *widget, GdkEvent *event,
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
296 GtkIMHtmlToolbar *toolbar)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
297 {
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
298 if (widget != NULL) {
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
299 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL))
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
300 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), "");
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
301 else
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
302 gtk_imhtml_toggle_background(GTK_IMHTML(toolbar->imhtml), "");
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
303 }
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
304
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
305 if (toolbar->bgcolor_dialog != NULL)
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
306 {
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
307 gtk_widget_destroy(toolbar->bgcolor_dialog);
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
308 toolbar->bgcolor_dialog = NULL;
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
309 }
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
310 return FALSE;
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
311 }
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
312
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
313 static void
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
314 cancel_toolbar_bgcolor(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
315 {
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
316 destroy_toolbar_bgcolor(widget, NULL, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
317 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
318
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
319 static void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
320 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
321 GdkColor text_color;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
322 GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "purple_toolbar");
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
323 char *open_tag;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
324
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
325 open_tag = g_malloc(30);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
326 gtk_color_selection_get_current_color(colorsel, &text_color);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
327 g_snprintf(open_tag, 23, "#%02X%02X%02X",
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
328 text_color.red / 256,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
329 text_color.green / 256,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
330 text_color.blue / 256);
10777
5a9df3199615 [gaim-migrate @ 12392]
Sean Egan <seanegan@pidgin.im>
parents: 10732
diff changeset
331 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, NULL, NULL))
5a9df3199615 [gaim-migrate @ 12392]
Sean Egan <seanegan@pidgin.im>
parents: 10732
diff changeset
332 gtk_imhtml_toggle_backcolor(GTK_IMHTML(toolbar->imhtml), open_tag);
5a9df3199615 [gaim-migrate @ 12392]
Sean Egan <seanegan@pidgin.im>
parents: 10732
diff changeset
333 else
5a9df3199615 [gaim-migrate @ 12392]
Sean Egan <seanegan@pidgin.im>
parents: 10732
diff changeset
334 gtk_imhtml_toggle_background(GTK_IMHTML(toolbar->imhtml), open_tag);
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
335 g_free(open_tag);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
336
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
337 cancel_toolbar_bgcolor(NULL, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
338 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
339
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
340 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
341 toggle_bg_color(GtkWidget *color, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
342 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
343 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
344 GtkWidget *colorsel;
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
345 GdkColor bgcolor;
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10297
diff changeset
346 char *color = gtk_imhtml_get_current_backcolor(GTK_IMHTML(toolbar->imhtml));
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
347
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
348 if (!toolbar->bgcolor_dialog) {
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
349 GtkWidget *ok_button;
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
350 GtkWidget *cancel_button;
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
351
8359
3c62ea91eba8 [gaim-migrate @ 9083]
Mark Doliner <markdoliner@pidgin.im>
parents: 8325
diff changeset
352 toolbar->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color"));
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
353 colorsel =
33130
a27897de32a4 Fix a small copy-paste bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33120
diff changeset
354 gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(toolbar->bgcolor_dialog));
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
355
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
356 if (color) {
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
357 gdk_color_parse(color, &bgcolor);
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
358 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor);
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10297
diff changeset
359 g_free(color);
9025
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
360 }
e49a72896270 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
361
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
362 g_object_set_data(G_OBJECT(colorsel), "purple_toolbar", toolbar);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
363
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
364 g_object_get(G_OBJECT(toolbar->bgcolor_dialog), "ok-button", &ok_button, NULL);
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
365 g_object_get(G_OBJECT(toolbar->bgcolor_dialog), "cancel-button",
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
366 &cancel_button, NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
367 g_signal_connect(G_OBJECT(toolbar->bgcolor_dialog), "delete_event",
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
368 G_CALLBACK(destroy_toolbar_bgcolor), toolbar);
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
369 g_signal_connect(G_OBJECT(ok_button), "clicked",
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
370 G_CALLBACK(do_bgcolor), colorsel);
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
371 g_signal_connect(G_OBJECT(cancel_button), "clicked",
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
372 G_CALLBACK(cancel_toolbar_bgcolor), toolbar);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
373
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
374 }
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
375 gtk_window_present(GTK_WINDOW(toolbar->bgcolor_dialog));
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
376 } else {
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
377 cancel_toolbar_bgcolor(color, toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
378 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
379 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
380 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
381
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
382 static void
11271
939be1fdbf7a [gaim-migrate @ 13454]
Richard Laager <rlaager@pidgin.im>
parents: 11267
diff changeset
383 clear_formatting_cb(GtkWidget *clear, GtkIMHtmlToolbar *toolbar)
939be1fdbf7a [gaim-migrate @ 13454]
Richard Laager <rlaager@pidgin.im>
parents: 11267
diff changeset
384 {
11275
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
385 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->clear), FALSE, toolbar);
11271
939be1fdbf7a [gaim-migrate @ 13454]
Richard Laager <rlaager@pidgin.im>
parents: 11267
diff changeset
386 gtk_imhtml_clear_formatting(GTK_IMHTML(toolbar->imhtml));
939be1fdbf7a [gaim-migrate @ 13454]
Richard Laager <rlaager@pidgin.im>
parents: 11267
diff changeset
387 }
939be1fdbf7a [gaim-migrate @ 13454]
Richard Laager <rlaager@pidgin.im>
parents: 11267
diff changeset
388
939be1fdbf7a [gaim-migrate @ 13454]
Richard Laager <rlaager@pidgin.im>
parents: 11267
diff changeset
389 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
390 cancel_link_cb(GtkIMHtmlToolbar *toolbar, PurpleRequestFields *fields)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
391 {
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
392 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE);
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
393
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
394 toolbar->link_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
395 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
396
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
397 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
398 close_link_dialog(GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
399 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
400 if (toolbar->link_dialog != NULL)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
401 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
402 purple_request_close(PURPLE_REQUEST_FIELDS, toolbar->link_dialog);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
403 toolbar->link_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
404 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
405 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
406
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
407 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
408 do_insert_link_cb(GtkIMHtmlToolbar *toolbar, PurpleRequestFields *fields)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
409 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
410 const char *url, *description;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
411
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
412 url = purple_request_fields_get_string(fields, "url");
9041
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
413 if (GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
414 description = purple_request_fields_get_string(fields, "description");
9041
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
415 else
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
416 description = NULL;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
417
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
418 if (description == NULL)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
419 description = url;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
420
8677
18b494207322 [gaim-migrate @ 9430]
Tim Ringenbach <marv@pidgin.im>
parents: 8516
diff changeset
421 gtk_imhtml_insert_link(GTK_IMHTML(toolbar->imhtml),
18b494207322 [gaim-migrate @ 9430]
Tim Ringenbach <marv@pidgin.im>
parents: 8516
diff changeset
422 gtk_text_buffer_get_insert(GTK_IMHTML(toolbar->imhtml)->text_buffer),
18b494207322 [gaim-migrate @ 9430]
Tim Ringenbach <marv@pidgin.im>
parents: 8516
diff changeset
423 url, description);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
424
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
425 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), FALSE);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
426
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
427 toolbar->link_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
428 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
429
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
430 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
431 insert_link_cb(GtkWidget *w, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
432 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
433 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
434 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
435 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
436 PurpleRequestField *field;
9599
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
437 GtkTextIter start, end;
9041
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
438 char *msg;
9599
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
439 char *desc = NULL;
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
440
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
441 fields = purple_request_fields_new();
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
442
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
443 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
444 purple_request_fields_add_group(fields, group);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
445
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
446 field = purple_request_field_string_new("url", _("_URL"), NULL, FALSE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
447 purple_request_field_set_required(field, TRUE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
448 purple_request_field_group_add_field(group, field);
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
449
9041
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
450 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) {
9599
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
451 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, &start, &end)) {
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
452 desc = gtk_imhtml_get_text(GTK_IMHTML(toolbar->imhtml), &start, &end);
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
453 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
454 field = purple_request_field_string_new("description", _("_Description"),
9599
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
455 desc, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
456 purple_request_field_group_add_field(group, field);
9041
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
457 msg = g_strdup(_("Please enter the URL and description of the "
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
458 "link that you want to insert. The description "
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
459 "is optional."));
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
460 } else {
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
461 msg = g_strdup(_("Please enter the URL of the "
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
462 "link that you want to insert."));
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
463 }
8319
6c18762beceb [gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents: 8317
diff changeset
464
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
465 toolbar->link_dialog =
21653
621c47778132 merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents: 21233
diff changeset
466 purple_request_fields(toolbar, _("Insert Link"),
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
467 NULL,
21653
621c47778132 merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents: 21233
diff changeset
468 msg,
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
469 fields,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
470 _("_Insert"), G_CALLBACK(do_insert_link_cb),
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
471 _("Cancel"), G_CALLBACK(cancel_link_cb),
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 33683
diff changeset
472 NULL,
21653
621c47778132 merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents: 21233
diff changeset
473 toolbar);
9041
cbded2eb14d7 [gaim-migrate @ 9817]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9027
diff changeset
474 g_free(msg);
9599
1089c73e0586 [gaim-migrate @ 10442]
Tim Ringenbach <marv@pidgin.im>
parents: 9522
diff changeset
475 g_free(desc);
8322
9bae68fd2612 [gaim-migrate @ 9046]
Christian Hammond <chipx86@chipx86.com>
parents: 8321
diff changeset
476 } else {
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
477 close_link_dialog(toolbar);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
478 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
479 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
480 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
481
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
482 static void insert_hr_cb(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
483 {
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
484 GtkTextIter iter;
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
485 GtkTextMark *ins;
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
486 GtkIMHtmlScalable *hr;
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
487
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
488 ins = gtk_text_buffer_get_insert(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)));
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
489 gtk_text_buffer_get_iter_at_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)), &iter, ins);
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
490 hr = gtk_imhtml_hr_new();
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
491 gtk_imhtml_hr_add_to(hr, GTK_IMHTML(toolbar->imhtml), &iter);
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
492 }
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
493
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
494 static void
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
495 do_insert_image_cb(GtkWidget *widget, int response, GtkIMHtmlToolbar *toolbar)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
496 {
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
497 gchar *filename, *name, *buf;
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
498 char *filedata;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
499 size_t size;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
500 GError *error = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
501 int id;
8962
5cd12e525d95 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
502 GtkTextIter iter;
5cd12e525d95 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
503 GtkTextMark *ins;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
504
21985
bf0e936998e4 Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21954
diff changeset
505 if (response != GTK_RESPONSE_ACCEPT)
bf0e936998e4 Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21954
diff changeset
506 {
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
507 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
508 return;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
509 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
510
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
511 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
512
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
513 if (filename == NULL) {
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
514 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
515 return;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
516 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
517
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
518 /* The following triggers a callback that closes the widget */
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
519 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), FALSE);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
520
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
521 if (!g_file_get_contents(filename, &filedata, &size, &error)) {
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
522 purple_notify_error(NULL, NULL, error->message, NULL, NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
523
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
524 g_error_free(error);
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
525 g_free(filename);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
526
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
527 return;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
528 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
529
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
530 name = strrchr(filename, G_DIR_SEPARATOR) + 1;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
531
33661
2ebcb105e606 Rename two functions.
Mark Doliner <mark@kingant.net>
parents: 33182
diff changeset
532 id = purple_imgstore_new_with_id(filedata, size, name);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
533
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
534 if (id == 0) {
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
535 buf = g_strdup_printf(_("Failed to store image: %s\n"), filename);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
536 purple_notify_error(NULL, NULL, buf, NULL, NULL);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
537
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
538 g_free(buf);
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
539 g_free(filename);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
540
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
541 return;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
542 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
543
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
544 g_free(filename);
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
545
8962
5cd12e525d95 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
546 ins = gtk_text_buffer_get_insert(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)));
5cd12e525d95 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
547 gtk_text_buffer_get_iter_at_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(toolbar->imhtml)),
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
548 &iter, ins);
8962
5cd12e525d95 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8892
diff changeset
549 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(toolbar->imhtml), id, &iter);
16437
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 16263
diff changeset
550 purple_imgstore_unref_by_id(id);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
551 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
552
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
553
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
554 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
555 insert_image_cb(GtkWidget *save, GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
556 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
557 GtkWidget *window;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
558
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
559 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))) {
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
560 window = gtk_file_chooser_dialog_new(_("Insert Image"),
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
561 NULL,
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
562 GTK_FILE_CHOOSER_ACTION_OPEN,
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
563 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
564 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
565 NULL);
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
566 gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_ACCEPT);
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
567 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(window)),
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
568 "response", G_CALLBACK(do_insert_image_cb), toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
569
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
570 gtk_widget_show(window);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
571 toolbar->image_dialog = window;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
572 } else {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
573 gtk_widget_destroy(toolbar->image_dialog);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
574 toolbar->image_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
575 }
9522
e38381bd8c05 [gaim-migrate @ 10349]
Mark Doliner <markdoliner@pidgin.im>
parents: 9287
diff changeset
576
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
577 gtk_widget_grab_focus(toolbar->imhtml);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
578 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
579
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
580
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
581 static void
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
582 destroy_smiley_dialog(GtkIMHtmlToolbar *toolbar)
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
583 {
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
584 if (toolbar->smiley_dialog != NULL)
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
585 {
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
586 gtk_widget_destroy(toolbar->smiley_dialog);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
587 toolbar->smiley_dialog = NULL;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
588 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
589 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
590
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
591 static gboolean
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
592 close_smiley_dialog(GtkIMHtmlToolbar *toolbar)
10134
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
593 {
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
594 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smiley), FALSE);
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21985
diff changeset
595 return FALSE;
10134
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
596 }
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
597
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
598
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
599 static void
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
600 insert_smiley_text(GtkWidget *widget, GtkIMHtmlToolbar *toolbar)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
601 {
9027
d4e9c928e913 [gaim-migrate @ 9803]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9025
diff changeset
602 char *smiley_text, *escaped_smiley;
d4e9c928e913 [gaim-migrate @ 9803]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9025
diff changeset
603
d4e9c928e913 [gaim-migrate @ 9803]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9025
diff changeset
604 smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text");
10732
5e314ab498bf [gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents: 10504
diff changeset
605 escaped_smiley = g_markup_escape_text(smiley_text, -1);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
606
8456
63fcac86a8fd [gaim-migrate @ 9186]
Gary Kramlich <grim@pidgin.im>
parents: 8447
diff changeset
607 gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml),
63fcac86a8fd [gaim-migrate @ 9186]
Gary Kramlich <grim@pidgin.im>
parents: 8447
diff changeset
608 GTK_IMHTML(toolbar->imhtml)->protocol_name,
9027
d4e9c928e913 [gaim-migrate @ 9803]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9025
diff changeset
609 escaped_smiley);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
610
9027
d4e9c928e913 [gaim-migrate @ 9803]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9025
diff changeset
611 g_free(escaped_smiley);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
612
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
613 close_smiley_dialog(toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
614 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
615
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
616 /* smiley buttons list */
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
617 struct smiley_button_list {
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
618 int width, height;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
619 GtkWidget *button;
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
620 const GtkIMHtmlSmiley *smiley;
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
621 struct smiley_button_list *next;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
622 };
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
623
11862
5d4bc6d54688 [gaim-migrate @ 14153]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11849
diff changeset
624 static struct smiley_button_list *
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
625 sort_smileys(struct smiley_button_list *ls, GtkIMHtmlToolbar *toolbar,
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
626 int *width, const GtkIMHtmlSmiley *smiley)
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
627 {
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
628 GtkWidget *image;
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
629 GtkWidget *button;
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
630 GtkRequisition size;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
631 struct smiley_button_list *cur;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
632 struct smiley_button_list *it, *it_last;
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
633 const gchar *filename = smiley->file;
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
634 gchar *face = smiley->smile;
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
635 PurpleSmiley *psmiley = NULL;
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
636 gboolean supports_custom = (gtk_imhtml_get_format_functions(GTK_IMHTML(toolbar->imhtml)) & GTK_IMHTML_CUSTOM_SMILEY);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
637
23003
aaab954eed6b Plug a small memory leak in the smiley dialog, and use g_new0/g_free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
638 cur = g_new0(struct smiley_button_list, 1);
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
639 it = ls;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
640 it_last = ls; /* list iterators*/
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
641 image = gtk_image_new_from_file(filename);
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
642
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
643 gtk_widget_size_request(image, &size);
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
644
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
645 if (size.width > 24 &&
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
646 smiley->flags & GTK_IMHTML_SMILEY_CUSTOM) { /* This is a custom smiley, let's scale it */
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
647 GdkPixbuf *pixbuf = NULL;
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
648 GtkImageType type;
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
649
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
650 type = gtk_image_get_storage_type(GTK_IMAGE(image));
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
651
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
652 if (type == GTK_IMAGE_PIXBUF) {
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
653 pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
23009
0bac25fdc9aa Unref some gdkpixbufs to plug some memory leaks. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23008
diff changeset
654 } else if (type == GTK_IMAGE_ANIMATION) {
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
655 GdkPixbufAnimation *animation;
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
656
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
657 animation = gtk_image_get_animation(GTK_IMAGE(image));
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
658
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
659 pixbuf = gdk_pixbuf_animation_get_static_image(animation);
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
660 }
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
661
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
662 if (pixbuf != NULL) {
23009
0bac25fdc9aa Unref some gdkpixbufs to plug some memory leaks. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23008
diff changeset
663 GdkPixbuf *resized;
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
664 resized = gdk_pixbuf_scale_simple(pixbuf, 24, 24,
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
665 GDK_INTERP_HYPER);
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
666
23011
33ff8a373a92 A leak fix from malu. Thanks!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23010
diff changeset
667 gtk_image_set_from_pixbuf(GTK_IMAGE(image), resized); /* This unrefs pixbuf */
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
668 gtk_widget_size_request(image, &size);
23009
0bac25fdc9aa Unref some gdkpixbufs to plug some memory leaks. References #1187.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23008
diff changeset
669 g_object_unref(G_OBJECT(resized));
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
670 }
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
671 }
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
672
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
673 (*width) += size.width;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
674
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
675 button = gtk_button_new();
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
676 gtk_container_add(GTK_CONTAINER(button), image);
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
677
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
678 g_object_set_data(G_OBJECT(button), "smiley_text", face);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
679 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
680
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26482
diff changeset
681 gtk_widget_set_tooltip_text(button, face);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
682
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
683 /* these look really weird with borders */
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
684 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
685
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
686 psmiley = purple_smileys_find_by_shortcut(smiley->smile);
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
687 /* If this is a "non-custom" smiley, check to see if its shortcut is
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
688 "shadowed" by any custom smiley. This can only happen if the connection
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
689 is custom smiley-enabled */
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
690 if (supports_custom && psmiley && !(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) {
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
691 gchar tip[128];
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24275
diff changeset
692 g_snprintf(tip, sizeof(tip),
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
693 _("This smiley is disabled because a custom smiley exists for this shortcut:\n %s"),
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
694 face);
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26482
diff changeset
695 gtk_widget_set_tooltip_text(button, tip);
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
696 gtk_widget_set_sensitive(button, FALSE);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
697 } else if (psmiley) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
698 /* Remove the button if the smiley is destroyed */
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
699 g_signal_connect_object(G_OBJECT(psmiley), "destroy", G_CALLBACK(gtk_widget_destroy),
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
700 button, G_CONNECT_SWAPPED);
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
701 }
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
702
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
703 /* set current element to add */
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
704 cur->height = size.height;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
705 cur->width = size.width;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
706 cur->button = button;
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
707 cur->smiley = smiley;
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
708 cur->next = ls;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
709
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
710 /* check where to insert by height */
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
711 if (ls == NULL)
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
712 return cur;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
713 while (it != NULL) {
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
714 it_last = it;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
715 it = it->next;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
716 }
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
717 cur->next = it;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
718 it_last->next = cur;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
719 return ls;
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
720 }
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
721
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
722 static gboolean
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
723 smiley_is_unique(GSList *list, GtkIMHtmlSmiley *smiley)
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
724 {
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
725 while (list) {
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
726 GtkIMHtmlSmiley *cur = (GtkIMHtmlSmiley *) list->data;
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
727 if (!strcmp(cur->file, smiley->file))
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
728 return FALSE;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
729 list = list->next;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
730 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
731 return TRUE;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
732 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
733
17394
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
734 static gboolean
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
735 smiley_dialog_input_cb(GtkWidget *dialog, GdkEvent *event, GtkIMHtmlToolbar *toolbar)
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
736 {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
737 if ((event->type == GDK_KEY_PRESS && event->key.keyval == GDK_KEY_Escape) ||
18546
3515b5b454e9 Rework the logic to be (IMHO) easy to read.
Richard Laager <rlaager@pidgin.im>
parents: 18545
diff changeset
738 (event->type == GDK_BUTTON_PRESS && event->button.button == 1))
3515b5b454e9 Rework the logic to be (IMHO) easy to read.
Richard Laager <rlaager@pidgin.im>
parents: 18545
diff changeset
739 {
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
740 close_smiley_dialog(toolbar);
18546
3515b5b454e9 Rework the logic to be (IMHO) easy to read.
Richard Laager <rlaager@pidgin.im>
parents: 18545
diff changeset
741 return TRUE;
3515b5b454e9 Rework the logic to be (IMHO) easy to read.
Richard Laager <rlaager@pidgin.im>
parents: 18545
diff changeset
742 }
17394
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
743
18546
3515b5b454e9 Rework the logic to be (IMHO) easy to read.
Richard Laager <rlaager@pidgin.im>
parents: 18545
diff changeset
744 return FALSE;
17394
ebe5e0e583da Close smiley dialog on GDK_Escape or button 1 press.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17303
diff changeset
745 }
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
746
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
747 static void
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
748 add_smiley_list(GtkWidget *container, struct smiley_button_list *list,
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
749 int max_width, gboolean custom)
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
750 {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
751 GtkWidget *line;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
752 int line_width = 0;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
753
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
754 if (!list)
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
755 return;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
756
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
757 line = gtk_hbox_new(FALSE, 0);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
758 gtk_box_pack_start(GTK_BOX(container), line, FALSE, FALSE, 0);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
759 for (; list; list = list->next) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
760 if (custom != !!(list->smiley->flags & GTK_IMHTML_SMILEY_CUSTOM))
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
761 continue;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
762 gtk_box_pack_start(GTK_BOX(line), list->button, FALSE, FALSE, 0);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
763 gtk_widget_show(list->button);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
764 line_width += list->width;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
765 if (line_width >= max_width) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
766 if (list->next) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
767 line = gtk_hbox_new(FALSE, 0);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
768 gtk_box_pack_start(GTK_BOX(container), line, FALSE, FALSE, 0);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
769 }
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
770 line_width = 0;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
771 }
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
772 }
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
773 }
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
774
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
775 static void
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
776 insert_smiley_cb(GtkWidget *smiley, GtkIMHtmlToolbar *toolbar)
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
777 {
23296
7f870792ce29 Put the 'manage' button outside the scrolling area.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23289
diff changeset
778 GtkWidget *dialog, *vbox;
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
779 GtkWidget *smiley_table = NULL;
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
780 GSList *smileys, *unique_smileys = NULL;
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
781 const GSList *custom_smileys = NULL;
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
782 gboolean supports_custom = FALSE;
23019
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
783 GtkRequisition req;
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
784 GtkWidget *scrolled, *viewport;
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
785
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
786 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
787 destroy_smiley_dialog(toolbar);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
788 gtk_widget_grab_focus(toolbar->imhtml);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
789 return;
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
790 }
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
791
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
792 if (toolbar->sml)
16263
27e0ef0f38e6 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents: 16254
diff changeset
793 smileys = pidgin_themes_get_proto_smileys(toolbar->sml);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
794 else
16263
27e0ef0f38e6 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents: 16254
diff changeset
795 smileys = pidgin_themes_get_proto_smileys(NULL);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
796
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
797 /* Note: prepend smileys to list to avoid O(n^2) overhead when there is
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
798 a large number of smileys... need to revers the list after for the dialog
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
799 work... */
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
800 while(smileys) {
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
801 GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) smileys->data;
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
802 if(!smiley->hidden) {
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
803 if(smiley_is_unique(unique_smileys, smiley)) {
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
804 unique_smileys = g_slist_prepend(unique_smileys, smiley);
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
805 }
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
806 }
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
807 smileys = smileys->next;
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
808 }
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
809 supports_custom = (gtk_imhtml_get_format_functions(GTK_IMHTML(toolbar->imhtml)) & GTK_IMHTML_CUSTOM_SMILEY);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
810 if (toolbar->imhtml && supports_custom) {
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
811 const GSList *iterator = NULL;
23010
6230fac29cee Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23009
diff changeset
812 custom_smileys = pidgin_smileys_get_all();
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
813
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
814 for (iterator = custom_smileys ; iterator ;
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
815 iterator = g_slist_next(iterator)) {
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
816 GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) iterator->data;
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
817 unique_smileys = g_slist_prepend(unique_smileys, smiley);
23010
6230fac29cee Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23009
diff changeset
818 }
22443
7b8772af6bb7 Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
819 }
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24275
diff changeset
820
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
821 /* we need to reverse the list to get the smileys in the correct order */
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
822 unique_smileys = g_slist_reverse(unique_smileys);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
823
22099
8e70e3ba6096 Modified patch from Gabriel (Sylar?) Schulof to deprecate PIDGIN_DIALOG. Closes #4535. (PS: I am aware of --author).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22032
diff changeset
824 dialog = pidgin_create_dialog(_("Smile!"), 0, "smiley_dialog", FALSE);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
825 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
23296
7f870792ce29 Put the 'manage' button outside the scrolling area.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23289
diff changeset
826 vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(dialog), FALSE, 0);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
827
15847
da522f9a7743 Don't use g_list_length() and g_slist_length() when all you want to
Mark Doliner <markdoliner@pidgin.im>
parents: 15623
diff changeset
828 if (unique_smileys != NULL) {
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
829 struct smiley_button_list *ls;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
830 int max_line_width, num_lines, button_width = 0;
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
831
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
832 /* We use hboxes packed in a vbox */
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
833 ls = NULL;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
834 max_line_width = 0;
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
835 num_lines = floor(sqrt(g_slist_length(unique_smileys)));
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
836 smiley_table = gtk_vbox_new(FALSE, 0);
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
837
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
838 if (supports_custom) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
839 GtkWidget *manage = gtk_button_new_with_mnemonic(_("_Manage custom smileys"));
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
840 GtkRequisition req;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
841 g_signal_connect(G_OBJECT(manage), "clicked",
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
842 G_CALLBACK(pidgin_smiley_manager_show), NULL);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
843 g_signal_connect_swapped(G_OBJECT(manage), "clicked",
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
844 G_CALLBACK(gtk_widget_destroy), dialog);
23296
7f870792ce29 Put the 'manage' button outside the scrolling area.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23289
diff changeset
845 gtk_box_pack_end(GTK_BOX(vbox), manage, FALSE, TRUE, 0);
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
846 gtk_widget_size_request(manage, &req);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
847 button_width = req.width;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
848 }
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
849
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
850 /* create list of smileys sorted by height */
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
851 while (unique_smileys) {
23014
d406337e359a Patch from malu (mlundblad) to disable a regular smiley in the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23011
diff changeset
852 GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) unique_smileys->data;
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
853 if (!smiley->hidden) {
23484
8ee3e86bfdca Do not disable default smileys with dupliate shortcuts if custom smileys
Marcus Lundblad <malu@pidgin.im>
parents: 23368
diff changeset
854 ls = sort_smileys(ls, toolbar, &max_line_width, smiley);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
855 }
23003
aaab954eed6b Plug a small memory leak in the smiley dialog, and use g_new0/g_free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22218
diff changeset
856 unique_smileys = g_slist_delete_link(unique_smileys, unique_smileys);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
857 }
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
858 /* The window will be at least as wide as the 'Manage ..' button */
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
859 max_line_width = MAX(button_width, max_line_width / num_lines);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
860
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
861 /* pack buttons of the list */
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
862 add_smiley_list(smiley_table, ls, max_line_width, FALSE);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
863 if (supports_custom) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
864 gtk_box_pack_start(GTK_BOX(smiley_table), gtk_hseparator_new(), TRUE, FALSE, 0);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
865 add_smiley_list(smiley_table, ls, max_line_width, TRUE);
10894
b75b237a1212 [gaim-migrate @ 12608]
Benjamin Canou <bookeldor@gmail.com>
parents: 10814
diff changeset
866 }
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
867 while (ls) {
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
868 struct smiley_button_list *tmp = ls->next;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
869 g_free(ls);
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
870 ls = tmp;
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
871 }
18547
cb6e8c0a08ca Rework the smiley dialog close logic: Escape will always close the window.
Richard Laager <rlaager@pidgin.im>
parents: 18546
diff changeset
872
cb6e8c0a08ca Rework the smiley dialog close logic: Escape will always close the window.
Richard Laager <rlaager@pidgin.im>
parents: 18546
diff changeset
873 gtk_widget_add_events(dialog, GDK_KEY_PRESS_MASK);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
874 }
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
875 else {
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
876 smiley_table = gtk_label_new(_("This theme has no available smileys."));
18547
cb6e8c0a08ca Rework the smiley dialog close logic: Escape will always close the window.
Richard Laager <rlaager@pidgin.im>
parents: 18546
diff changeset
877 gtk_widget_add_events(dialog, GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK);
cb6e8c0a08ca Rework the smiley dialog close logic: Escape will always close the window.
Richard Laager <rlaager@pidgin.im>
parents: 18546
diff changeset
878 g_signal_connect(G_OBJECT(dialog), "button-press-event", (GCallback)smiley_dialog_input_cb, toolbar);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
879 }
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
880
31321
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31309
diff changeset
881
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31309
diff changeset
882 scrolled = pidgin_make_scrollable(smiley_table, GTK_POLICY_NEVER, GTK_POLICY_NEVER, GTK_SHADOW_NONE, -1, -1);
23296
7f870792ce29 Put the 'manage' button outside the scrolling area.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23289
diff changeset
883 gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
884 gtk_widget_show(smiley_table);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
885
23019
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
886 viewport = gtk_widget_get_parent(smiley_table);
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
887 gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
888
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
889 /* connect signals */
23016
6cdca784716b Separate the custom smileys from the regular smileys, and add a 'Manage'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23015
diff changeset
890 g_signal_connect_swapped(G_OBJECT(dialog), "destroy", G_CALLBACK(close_smiley_dialog), toolbar);
23019
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
891 g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(smiley_dialog_input_cb), toolbar);
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
892
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
893 gtk_window_set_transient_for(GTK_WINDOW(dialog),
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
894 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(toolbar))));
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
895
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
896 /* show everything */
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
897 gtk_widget_show_all(dialog);
23019
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
898
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
899 gtk_widget_size_request(viewport, &req);
23296
7f870792ce29 Put the 'manage' button outside the scrolling area.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23289
diff changeset
900 gtk_widget_set_size_request(scrolled, MIN(300, req.width), MIN(290, req.height));
23019
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
901
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
902 /* The window has to be made resizable, and the scrollbars in the scrolled window
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
903 * enabled only after setting the desired size of the window. If we do either of
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
904 * these tasks before now, GTK+ miscalculates the required size, and erronously
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
905 * makes one or both scrollbars visible (sometimes).
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
906 * I too think this hack is gross. But I couldn't find a better way -- sadrul */
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
907 gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
31321
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31309
diff changeset
908 g_object_set(G_OBJECT(scrolled),
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31309
diff changeset
909 "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31309
diff changeset
910 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31309
diff changeset
911 NULL);
23019
427ce09896f8 Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23016
diff changeset
912
20719
ce876ae5fb7d Prevent the smiley window appearing outside of the working area on win32. Fixes #3261.
Daniel Atallah <datallah@pidgin.im>
parents: 20387
diff changeset
913 #ifdef _WIN32
ce876ae5fb7d Prevent the smiley window appearing outside of the working area on win32. Fixes #3261.
Daniel Atallah <datallah@pidgin.im>
parents: 20387
diff changeset
914 winpidgin_ensure_onscreen(dialog);
ce876ae5fb7d Prevent the smiley window appearing outside of the working area on win32. Fixes #3261.
Daniel Atallah <datallah@pidgin.im>
parents: 20387
diff changeset
915 #endif
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
916
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
917 toolbar->smiley_dialog = dialog;
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
918
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
919 gtk_widget_grab_focus(toolbar->imhtml);
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
920 }
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
921
24457
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
922 static void send_attention_cb(GtkWidget *attention, GtkIMHtmlToolbar *toolbar)
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
923 {
29482
eef3bb59b723 Temporary workaround to not break ABI, to allow this in for 2.7.0
Marcus Lundblad <malu@pidgin.im>
parents: 28573
diff changeset
924 PurpleConversation *conv =
eef3bb59b723 Temporary workaround to not break ABI, to allow this in for 2.7.0
Marcus Lundblad <malu@pidgin.im>
parents: 28573
diff changeset
925 g_object_get_data(G_OBJECT(toolbar), "active_conv");
25922
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
926 const gchar *who = purple_conversation_get_name(conv);
32698
154e4a2a6287 Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31321
diff changeset
927 PurpleConnection *gc = purple_conversation_get_connection(conv);
29482
eef3bb59b723 Temporary workaround to not break ABI, to allow this in for 2.7.0
Marcus Lundblad <malu@pidgin.im>
parents: 28573
diff changeset
928
eef3bb59b723 Temporary workaround to not break ABI, to allow this in for 2.7.0
Marcus Lundblad <malu@pidgin.im>
parents: 28573
diff changeset
929 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(attention), FALSE, toolbar);
25922
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
930 purple_prpl_send_attention(gc, who, 0);
30421
043e250a4339 pidgin: Re-set focus after clicking on the attention button.
Marcus Lundblad <malu@pidgin.im>
parents: 30408
diff changeset
931 gtk_widget_grab_focus(toolbar->imhtml);
24457
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
932 }
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
933
8420
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
934 static void update_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
935 {
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
936 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bold), buttons & GTK_IMHTML_BOLD);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
937 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->italic), buttons & GTK_IMHTML_ITALIC);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
938 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->underline), buttons & GTK_IMHTML_UNDERLINE);
19719
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
939 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->strikethrough), buttons & GTK_IMHTML_STRIKE);
8420
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
940
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
941 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->larger_size), buttons & GTK_IMHTML_GROW);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
942 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smaller_size), buttons & GTK_IMHTML_SHRINK);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
943
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
944 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->font), buttons & GTK_IMHTML_FACE);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
945 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->fgcolor), buttons & GTK_IMHTML_FORECOLOR);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
946 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->bgcolor), buttons & GTK_IMHTML_BACKCOLOR);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
947
11314
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
948 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->clear),
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
949 (buttons & GTK_IMHTML_BOLD ||
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
950 buttons & GTK_IMHTML_ITALIC ||
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
951 buttons & GTK_IMHTML_UNDERLINE ||
19719
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
952 buttons & GTK_IMHTML_STRIKE ||
11314
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
953 buttons & GTK_IMHTML_GROW ||
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
954 buttons & GTK_IMHTML_SHRINK ||
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
955 buttons & GTK_IMHTML_FACE ||
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
956 buttons & GTK_IMHTML_FORECOLOR ||
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
957 buttons & GTK_IMHTML_BACKCOLOR));
50888518c108 [gaim-migrate @ 13516]
Luke Schierer <lschiere@pidgin.im>
parents: 11313
diff changeset
958
8420
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
959 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->image), buttons & GTK_IMHTML_IMAGE);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
960 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->link), buttons & GTK_IMHTML_LINK);
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
961 gtk_widget_set_sensitive(GTK_WIDGET(toolbar->smiley), buttons & GTK_IMHTML_SMILEY);
8481
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
962 }
8420
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
963
8481
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
964 /* we call this when we want to _set_active the toggle button, it'll
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
965 * block the callback thats connected to the button so we don't have to
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
966 * do the double toggling hack
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
967 */
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
968 static void toggle_button_set_active_block(GtkToggleButton *button,
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
969 gboolean is_active,
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
970 GtkIMHtmlToolbar *toolbar)
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
971 {
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
972 GObject *object;
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
973 g_return_if_fail(toolbar);
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
974
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
975 object = g_object_ref(button);
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
976 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA,
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
977 0, 0, NULL, NULL, toolbar);
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
978 gtk_toggle_button_set_active(button, is_active);
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
979 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA,
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
980 0, 0, NULL, NULL, toolbar);
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
981 g_object_unref(object);
8420
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
982 }
71d59c4e2beb [gaim-migrate @ 9150]
Sean Egan <seanegan@pidgin.im>
parents: 8391
diff changeset
983
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
984 static void update_buttons(GtkIMHtmlToolbar *toolbar)
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
985 {
19719
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
986 gboolean bold, italic, underline, strike;
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
987 char *tmp;
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
988 char *tmp2;
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
989 GtkLabel *label = g_object_get_data(G_OBJECT(toolbar), "font_label");
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
990
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
991 gtk_label_set_label(label, _("_Font"));
10134
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
992
8516
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
993 gtk_imhtml_get_current_format(GTK_IMHTML(toolbar->imhtml),
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
994 &bold, &italic, &underline);
19719
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
995 strike = GTK_IMHTML(toolbar->imhtml)->edit.strike;
8506
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
996
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
997 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->bold)) != bold)
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
998 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bold), bold,
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
999 toolbar);
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1000 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->italic)) != italic)
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1001 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->italic), italic,
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1002 toolbar);
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1003 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->underline)) != underline)
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1004 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->underline),
8677
18b494207322 [gaim-migrate @ 9430]
Tim Ringenbach <marv@pidgin.im>
parents: 8516
diff changeset
1005 underline, toolbar);
19719
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1006 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->strikethrough)) != strike)
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1007 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->strikethrough),
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1008 strike, toolbar);
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1009
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1010 /* These buttons aren't ever "active". */
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1011 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->smaller_size), FALSE);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1012 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->larger_size), FALSE);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1013
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1014 if (bold) {
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1015 gchar *markup = g_strdup_printf("<b>%s</b>",
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1016 gtk_label_get_label(label));
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1017 gtk_label_set_markup_with_mnemonic(label, markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1018 g_free(markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1019 }
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1020 if (italic) {
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1021 gchar *markup = g_strdup_printf("<i>%s</i>",
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1022 gtk_label_get_label(label));
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1023 gtk_label_set_markup_with_mnemonic(label, markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1024 g_free(markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1025 }
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1026 if (underline) {
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1027 gchar *markup = g_strdup_printf("<u>%s</u>",
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1028 gtk_label_get_label(label));
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1029 gtk_label_set_markup_with_mnemonic(label, markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1030 g_free(markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1031 }
19719
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1032 if (strike) {
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1033 gchar *markup = g_strdup_printf("<s>%s</s>",
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1034 gtk_label_get_label(label));
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1035 gtk_label_set_markup_with_mnemonic(label, markup);
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1036 g_free(markup);
446e97aca498 Update the strikethrough state and the buttons as appropriate. Fixes #2884.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19647
diff changeset
1037 }
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1038
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1039 tmp = gtk_imhtml_get_current_fontface(GTK_IMHTML(toolbar->imhtml));
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1040 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->font),
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1041 (tmp != NULL), toolbar);
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1042 if (tmp != NULL) {
35126
669cb2286130 Remove "'fontdesc' attribute not allowed in <span>" warnings
Ankit Vani <a@nevitus.org>
parents: 34955
diff changeset
1043 gchar *markup = g_strdup_printf("<span face=\"%s\">%s</span>",
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1044 tmp, gtk_label_get_label(label));
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1045 gtk_label_set_markup_with_mnemonic(label, markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1046 g_free(markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1047 }
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1048 g_free(tmp);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1049
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1050 tmp = gtk_imhtml_get_current_forecolor(GTK_IMHTML(toolbar->imhtml));
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1051 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->fgcolor),
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1052 (tmp != NULL), toolbar);
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1053 if (tmp != NULL) {
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1054 gchar *markup = g_strdup_printf("<span foreground=\"%s\">%s</span>",
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1055 tmp, gtk_label_get_label(label));
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1056 gtk_label_set_markup_with_mnemonic(label, markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1057 g_free(markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1058 }
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1059 g_free(tmp);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1060
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1061 tmp = gtk_imhtml_get_current_backcolor(GTK_IMHTML(toolbar->imhtml));
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1062 tmp2 = gtk_imhtml_get_current_background(GTK_IMHTML(toolbar->imhtml));
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1063 toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->bgcolor),
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1064 (tmp != NULL || tmp2 != NULL), toolbar);
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1065 if (tmp != NULL) {
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1066 gchar *markup = g_strdup_printf("<span background=\"%s\">%s</span>",
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1067 tmp, gtk_label_get_label(label));
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1068 gtk_label_set_markup_with_mnemonic(label, markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1069 g_free(markup);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1070 }
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1071 g_free(tmp);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1072 g_free(tmp2);
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1073 }
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1074
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1075 static void toggle_button_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, GtkIMHtmlToolbar *toolbar)
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1076 {
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1077 update_buttons(toolbar);
8506
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1078 }
8481
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
1079
8516
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1080 static void update_format_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar) {
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1081 update_buttons(toolbar);
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1082 }
8481
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
1083
8516
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1084 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *location,
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1085 GtkTextMark *mark, GtkIMHtmlToolbar *toolbar)
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1086 {
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1087 if(mark != gtk_text_buffer_get_insert(buffer))
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1088 return;
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1089
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1090 update_buttons(toolbar);
8427
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1091 }
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1092
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1093
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1094 /* This comes from gtkmenutoolbutton.c from gtk+
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1095 * Copyright (C) 2003 Ricardo Fernandez Pascual
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1096 * Copyright (C) 2004 Paolo Borelli
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1097 */
17523
d26a1a21ea72 Fix a compile error and kill a bucket full of compile warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17498
diff changeset
1098 static void
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1099 menu_position_func (GtkMenu *menu,
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1100 int *x,
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1101 int *y,
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1102 gboolean *push_in,
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1103 gpointer data)
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1104 {
18238
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1105 GtkWidget *widget = GTK_WIDGET(data);
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1106 GtkRequisition menu_req;
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
1107 GtkAllocation allocation;
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414
diff changeset
1108 gint ythickness = gtk_widget_get_style(widget)->ythickness;
18238
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1109 int savy;
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1110
33158
ad941796372e Remove some added trailing spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33139
diff changeset
1111 gtk_widget_get_allocation(widget, &allocation);
18238
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1112 gtk_widget_size_request(GTK_WIDGET (menu), &menu_req);
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1113 gdk_window_get_origin(gtk_widget_get_window(widget), x, y);
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1114 *x += allocation.x;
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1115 *y += allocation.y + allocation.height;
18238
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1116 savy = *y;
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1117
18238
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1118 pidgin_menu_position_func_helper(menu, x, y, push_in, data);
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1119
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18185
diff changeset
1120 if (savy > *y + ythickness + 1)
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1121 *y -= allocation.height;
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1122 }
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1123
30408
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1124 static gboolean
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1125 button_activate_on_click(GtkWidget *button, GdkEventButton *event, GtkIMHtmlToolbar *toolbar)
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1126 {
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1127 if (event->button == 1 && GTK_IS_TOGGLE_BUTTON(button))
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1128 gtk_widget_activate(button);
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1129 else if (event->button == 3)
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1130 return gtk_imhtmltoolbar_popup_menu(button, event, toolbar);
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1131 return FALSE;
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1132 }
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1133
19213
e273393f4b75 The hotkeys should popup the menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19199
diff changeset
1134 static void pidgin_menu_clicked(GtkWidget *button, GtkMenu *menu)
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1135 {
19104
35cd69038e67 show toolbar menu on button press, rather than button release. Fixes #2352
Sean Egan <seanegan@pidgin.im>
parents: 19089
diff changeset
1136 gtk_widget_show_all(GTK_WIDGET(menu));
35cd69038e67 show toolbar menu on button press, rather than button release. Fixes #2352
Sean Egan <seanegan@pidgin.im>
parents: 19089
diff changeset
1137 gtk_menu_popup(menu, NULL, NULL, menu_position_func, button, 0, gtk_get_current_event_time());
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1138 }
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1139
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1140 static void pidgin_menu_deactivate(GtkWidget *menu, GtkToggleButton *button)
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1141 {
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1142 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1143 }
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1144
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1145 enum {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1146 LAST_SIGNAL
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1147 };
9863
323e4fe28791 [gaim-migrate @ 10742]
Mark Doliner <markdoliner@pidgin.im>
parents: 9791
diff changeset
1148 /* static guint signals [LAST_SIGNAL] = { 0 }; */
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1149
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1150 static void
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1151 gtk_imhtmltoolbar_finalize (GObject *object)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1152 {
8391
ed3b9c27d002 [gaim-migrate @ 9120]
Mark Doliner <markdoliner@pidgin.im>
parents: 8380
diff changeset
1153 GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object);
19073
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1154 GtkWidget *menu;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1155
8685
aea52455a3ba [gaim-migrate @ 9438]
Kevin Stange <kstange@pidgin.im>
parents: 8677
diff changeset
1156 if (toolbar->image_dialog != NULL)
aea52455a3ba [gaim-migrate @ 9438]
Kevin Stange <kstange@pidgin.im>
parents: 8677
diff changeset
1157 {
aea52455a3ba [gaim-migrate @ 9438]
Kevin Stange <kstange@pidgin.im>
parents: 8677
diff changeset
1158 gtk_widget_destroy(toolbar->image_dialog);
aea52455a3ba [gaim-migrate @ 9438]
Kevin Stange <kstange@pidgin.im>
parents: 8677
diff changeset
1159 toolbar->image_dialog = NULL;
aea52455a3ba [gaim-migrate @ 9438]
Kevin Stange <kstange@pidgin.im>
parents: 8677
diff changeset
1160 }
aea52455a3ba [gaim-migrate @ 9438]
Kevin Stange <kstange@pidgin.im>
parents: 8677
diff changeset
1161
10134
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
1162 destroy_toolbar_font(NULL, NULL, toolbar);
23368
76fd0254bae3 Prevent a crash when the imhtmltoolbar is disposed and the smiley dialog is open.
Daniel Atallah <datallah@pidgin.im>
parents: 23296
diff changeset
1163 if (toolbar->smiley_dialog != NULL) {
76fd0254bae3 Prevent a crash when the imhtmltoolbar is disposed and the smiley dialog is open.
Daniel Atallah <datallah@pidgin.im>
parents: 23296
diff changeset
1164 g_signal_handlers_disconnect_by_func(G_OBJECT(toolbar->smiley_dialog), close_smiley_dialog, toolbar);
76fd0254bae3 Prevent a crash when the imhtmltoolbar is disposed and the smiley dialog is open.
Daniel Atallah <datallah@pidgin.im>
parents: 23296
diff changeset
1165 destroy_smiley_dialog(toolbar);
76fd0254bae3 Prevent a crash when the imhtmltoolbar is disposed and the smiley dialog is open.
Daniel Atallah <datallah@pidgin.im>
parents: 23296
diff changeset
1166 }
10134
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
1167 destroy_toolbar_bgcolor(NULL, NULL, toolbar);
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
1168 destroy_toolbar_fgcolor(NULL, NULL, toolbar);
ecbf96117857 [gaim-migrate @ 11198]
Nathan Fredrickson <nathan@silverorange.com>
parents: 10125
diff changeset
1169 close_link_dialog(toolbar);
12904
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1170 if (toolbar->imhtml) {
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1171 g_signal_handlers_disconnect_matched(toolbar->imhtml,
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1172 G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1173 toolbar);
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1174 g_signal_handlers_disconnect_matched(GTK_IMHTML(toolbar->imhtml)->text_buffer,
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1175 G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1176 toolbar);
f01835b6bcac [gaim-migrate @ 15257]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12900
diff changeset
1177 }
8784
71c51aa52be4 [gaim-migrate @ 9546]
Kevin Stange <kstange@pidgin.im>
parents: 8756
diff changeset
1178
24275
37fca4e63b69 Use the correct free() function.
Daniel Atallah <datallah@pidgin.im>
parents: 23532
diff changeset
1179 g_free(toolbar->sml);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1180
19073
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1181 menu = g_object_get_data(object, "font_menu");
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1182 if (menu)
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1183 gtk_widget_destroy(menu);
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1184 menu = g_object_get_data(object, "insert_menu");
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1185 if (menu)
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1186 gtk_widget_destroy(menu);
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1187
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1188 purple_prefs_disconnect_by_handle(object);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1189
8391
ed3b9c27d002 [gaim-migrate @ 9120]
Mark Doliner <markdoliner@pidgin.im>
parents: 8380
diff changeset
1190 G_OBJECT_CLASS(parent_class)->finalize (object);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1191 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1192
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1193 static void
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1194 switch_toolbar_view(GtkWidget *item, GtkIMHtmlToolbar *toolbar)
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1195 {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1196 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1197 !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide"));
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1198 }
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1199
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1200 static gboolean
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1201 gtk_imhtmltoolbar_popup_menu(GtkWidget *widget, GdkEventButton *event, GtkIMHtmlToolbar *toolbar)
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1202 {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1203 GtkWidget *menu;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1204 GtkWidget *item;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1205 gboolean wide;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1206
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1207 if (event->button != 3)
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1208 return FALSE;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1209
32913
af2c726febce Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32900
diff changeset
1210 wide = gtk_widget_get_visible(toolbar->bold);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1211
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1212 menu = gtk_menu_new();
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1213 item = gtk_menu_item_new_with_mnemonic(wide ? _("Group Items") : _("Ungroup Items"));
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1214 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(switch_toolbar_view), toolbar);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1215 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1216 gtk_widget_show(item);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1217
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1218 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, pidgin_menu_position_func_helper,
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1219 widget, event->button, event->time);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1220 return TRUE;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1221 }
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1222
10814
7e17cb56b019 [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10777
diff changeset
1223 /* Boring GTK+ stuff */
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1224 static void gtk_imhtmltoolbar_class_init (GtkIMHtmlToolbarClass *class)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1225 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1226 GObjectClass *gobject_class;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1227 gobject_class = (GObjectClass*) class;
26828
ca76e7ad0d4b Oops, I must have been tired. I only replaced the first occurrence of these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26482
diff changeset
1228 parent_class = g_type_class_ref(GTK_TYPE_HBOX);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1229 gobject_class->finalize = gtk_imhtmltoolbar_finalize;
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1230
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1231 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations/toolbar");
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1232 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide", FALSE);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1233 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1234
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1235 static void gtk_imhtmltoolbar_create_old_buttons(GtkIMHtmlToolbar *toolbar)
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1236 {
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1237 GtkWidget *hbox;
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1238 GtkWidget *button;
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1239 struct {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1240 char *stock;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1241 gpointer callback;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1242 GtkWidget **button;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1243 const char *tooltip;
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1244 } buttons[] = {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1245 {GTK_STOCK_BOLD, G_CALLBACK(do_bold), &toolbar->bold, _("Bold")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1246 {GTK_STOCK_ITALIC, do_italic, &toolbar->italic, _("Italic")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1247 {GTK_STOCK_UNDERLINE, do_underline, &toolbar->underline, _("Underline")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1248 {GTK_STOCK_STRIKETHROUGH, do_strikethrough, &toolbar->strikethrough, _("Strikethrough")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1249 {"", NULL, NULL, NULL},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1250 {PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, do_big, &toolbar->larger_size, _("Increase Font Size")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1251 {PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, do_small, &toolbar->smaller_size, _("Decrease Font Size")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1252 {"", NULL, NULL, NULL},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1253 {PIDGIN_STOCK_TOOLBAR_FONT_FACE, toggle_font, &toolbar->font, _("Font Face")},
28258
ec6dd456b74c Re-order the ungrouped formatting toolbar buttons to match the order of the
Etan Reisner <deryni@pidgin.im>
parents: 28257
diff changeset
1254 {PIDGIN_STOCK_TOOLBAR_FGCOLOR, toggle_fg_color, &toolbar->fgcolor, _("Foreground Color")},
21954
ffb38ad2e4d6 Patch from DHowett to fix the transposition of background and forebround colors
Sean Egan <seanegan@pidgin.im>
parents: 21888
diff changeset
1255 {PIDGIN_STOCK_TOOLBAR_BGCOLOR, toggle_bg_color, &toolbar->bgcolor, _("Background Color")},
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1256 {"", NULL, NULL, NULL},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1257 {PIDGIN_STOCK_CLEAR, clear_formatting_cb, &toolbar->clear, _("Reset Formatting")},
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1258 {"", NULL, NULL, NULL},
28258
ec6dd456b74c Re-order the ungrouped formatting toolbar buttons to match the order of the
Etan Reisner <deryni@pidgin.im>
parents: 28257
diff changeset
1259 {PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, insert_image_cb, &toolbar->image, _("Insert IM Image")},
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1260 {PIDGIN_STOCK_TOOLBAR_INSERT_LINK, insert_link_cb, &toolbar->link, _("Insert Link")},
28258
ec6dd456b74c Re-order the ungrouped formatting toolbar buttons to match the order of the
Etan Reisner <deryni@pidgin.im>
parents: 28257
diff changeset
1261 {"", NULL, NULL, NULL},
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1262 {PIDGIN_STOCK_TOOLBAR_SMILEY, insert_smiley_cb, &toolbar->smiley, _("Insert Smiley")},
32699
09ff5997da90 Move the Attention toolbar button into the GtkIMHtmlToolbar struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32698
diff changeset
1263 {PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, send_attention_cb, &toolbar->attention, _("Send Attention")},
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1264 {NULL, NULL, NULL, NULL}
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1265 };
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1266 int iter;
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1267
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1268 hbox = gtk_hbox_new(FALSE, 0);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1269
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1270 for (iter = 0; buttons[iter].stock; iter++) {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1271 if (buttons[iter].stock[0]) {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1272 button = pidgin_pixbuf_toolbar_button_from_stock(buttons[iter].stock);
31309
eea56be9e0eb Fix clicking on buttons in formatting toolbar so they don't try (and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 31294
diff changeset
1273 g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(gtk_imhtmltoolbar_popup_menu), toolbar);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1274 g_signal_connect(G_OBJECT(button), "clicked",
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1275 G_CALLBACK(buttons[iter].callback), toolbar);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1276 *(buttons[iter].button) = button;
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26482
diff changeset
1277 gtk_widget_set_tooltip_text(button, buttons[iter].tooltip);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1278 } else
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1279 button = gtk_vseparator_new();
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1280 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1281 }
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1282
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1283 gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1284 g_object_set_data(G_OBJECT(toolbar), "wide-view", hbox);
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1285 }
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1286
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1287 static void
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1288 button_visibility_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1289 {
32913
af2c726febce Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32900
diff changeset
1290 if (gtk_widget_get_visible(button))
30489
1ce0f6617b57 Did I mention this is entirely untested? (I don't have GTK+ on
Paul Aurich <darkrain42@pidgin.im>
parents: 30488
diff changeset
1291 gtk_widget_hide(item);
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1292 else
30489
1ce0f6617b57 Did I mention this is entirely untested? (I don't have GTK+ on
Paul Aurich <darkrain42@pidgin.im>
parents: 30488
diff changeset
1293 gtk_widget_show(item);
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1294 }
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1295
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1296 static void
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1297 button_sensitiveness_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1298 {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1299 gtk_widget_set_sensitive(item, gtk_widget_get_sensitive(button));
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1300 }
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1301
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1302 static void
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1303 update_menuitem(GtkToggleButton *button, GtkCheckMenuItem *item)
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1304 {
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1305 g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1306 gtk_check_menu_item_set_active(item, gtk_toggle_button_get_active(button));
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1307 g_signal_handlers_unblock_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1308 }
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1309
19199
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1310 static void
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1311 enable_markup(GtkWidget *widget, gpointer null)
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1312 {
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1313 if (GTK_IS_LABEL(widget))
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1314 g_object_set(G_OBJECT(widget), "use-markup", TRUE, NULL);
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1315 }
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1316
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1317 static void
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1318 imhtmltoolbar_view_pref_changed(const char *name, PurplePrefType type,
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1319 gconstpointer value, gpointer toolbar)
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1320 {
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1321 if (value) {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1322 gtk_widget_hide(g_object_get_data(G_OBJECT(toolbar), "lean-view"));
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1323 gtk_widget_show_all(g_object_get_data(G_OBJECT(toolbar), "wide-view"));
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1324 } else {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
1325 gtk_widget_hide(g_object_get_data(G_OBJECT(toolbar), "wide-view"));
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1326 gtk_widget_show_all(g_object_get_data(G_OBJECT(toolbar), "lean-view"));
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1327 }
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1328 }
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1329
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1330 static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar)
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1331 {
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1332 GtkWidget *hbox = GTK_WIDGET(toolbar), *event = gtk_event_box_new();
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1333 GtkWidget *bbox, *box = gtk_hbox_new(FALSE, 0);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1334 GtkWidget *image;
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1335 GtkWidget *label;
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1336 GtkWidget *insert_button;
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1337 GtkWidget *font_button;
20328
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1338 GtkWidget *smiley_button;
24457
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1339 GtkWidget *attention_button;
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1340 GtkWidget *font_menu;
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1341 GtkWidget *insert_menu;
18240
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1342 GtkWidget *menuitem;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1343 GtkWidget *sep;
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1344 int i;
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1345 struct {
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1346 const char *label;
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1347 GtkWidget **button;
19076
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1348 gboolean check;
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1349 } buttons[] = {
19199
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1350 {_("<b>_Bold</b>"), &toolbar->bold, TRUE},
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1351 {_("<i>_Italic</i>"), &toolbar->italic, TRUE},
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1352 {_("<u>_Underline</u>"), &toolbar->underline, TRUE},
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
1353 {_("<span strikethrough='true'>Strikethrough</span>"), &toolbar->strikethrough, TRUE},
19199
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1354 {_("<span size='larger'>_Larger</span>"), &toolbar->larger_size, TRUE},
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1355 #if 0
19076
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1356 {_("_Normal"), &toolbar->normal_size, TRUE},
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1357 #endif
19199
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1358 {_("<span size='smaller'>_Smaller</span>"), &toolbar->smaller_size, TRUE},
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1359 /* If we want to show the formatting for the following items, we would
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1360 * need to update them when formatting changes. The above items don't need
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1361 * no updating nor nothin' */
19076
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1362 {_("_Font face"), &toolbar->font, TRUE},
19083
14edbc247c42 I thought I fixed this already...
Kevin Stange <kstange@pidgin.im>
parents: 19076
diff changeset
1363 {_("Foreground _color"), &toolbar->fgcolor, TRUE},
19084
15f91e441bfb Another mnemonic conflict
Kevin Stange <kstange@pidgin.im>
parents: 19083
diff changeset
1364 {_("Bac_kground color"), &toolbar->bgcolor, TRUE},
19076
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1365 {_("_Reset formatting"), &toolbar->clear, FALSE},
19088
8eb73fcef3ad Get rid of two minor compile warnings:
Mark Doliner <markdoliner@pidgin.im>
parents: 19076
diff changeset
1366 {NULL, NULL, FALSE}
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1367 };
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1368
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1369 toolbar->imhtml = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1370 toolbar->font_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1371 toolbar->fgcolor_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1372 toolbar->bgcolor_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1373 toolbar->link_dialog = NULL;
10138
b72c5fdc98b3 [gaim-migrate @ 11208]
Mark Doliner <markdoliner@pidgin.im>
parents: 10135
diff changeset
1374 toolbar->smiley_dialog = NULL;
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1375 toolbar->image_dialog = NULL;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1376
17303
138cbb17e5cd disapproval of revision '6e8f285962e77199bf88dfc8d2a08386beb02634'
Sean Egan <seanegan@pidgin.im>
parents: 17300
diff changeset
1377 gtk_box_set_spacing(GTK_BOX(toolbar), 3);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1378
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1379 gtk_imhtmltoolbar_create_old_buttons(toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1380
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1381 /* Fonts */
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1382 font_button = gtk_toggle_button_new();
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1383 gtk_button_set_relief(GTK_BUTTON(font_button), GTK_RELIEF_NONE);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1384 bbox = gtk_hbox_new(FALSE, 3);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1385 gtk_container_add(GTK_CONTAINER(font_button), bbox);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1386 image = gtk_image_new_from_stock(GTK_STOCK_BOLD, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1387 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1388 label = gtk_label_new_with_mnemonic(_("_Font"));
19068
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1389 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
4effc374e407 Show current outgoing conversation formatting on the font label on
Ka-Hing Cheung <khc@pidgin.im>
parents: 19061
diff changeset
1390 g_object_set_data(G_OBJECT(hbox), "font_label", label);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1391 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1392 gtk_box_pack_start(GTK_BOX(box), font_button, FALSE, FALSE, 0);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1393 gtk_widget_show_all(font_button);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1394
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1395 font_menu = gtk_menu_new();
19073
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1396 g_object_set_data(G_OBJECT(toolbar), "font_menu", font_menu);
17879
3e3f85138f1a merge of '87854ccfae544467c988edbac854c1ae2018eed4'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17620 17594
diff changeset
1397
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1398 for (i = 0; buttons[i].label; i++) {
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1399 GtkWidget *old = *buttons[i].button;
19076
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1400 if (buttons[i].check) {
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1401 menuitem = gtk_check_menu_item_new_with_mnemonic(buttons[i].label);
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1402 g_signal_connect_after(G_OBJECT(old), "toggled",
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1403 G_CALLBACK(update_menuitem), menuitem);
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1404 } else {
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1405 menuitem = gtk_menu_item_new_with_mnemonic(buttons[i].label);
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1406 }
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1407 g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1408 G_CALLBACK(gtk_button_clicked), old);
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1409 gtk_menu_shell_append(GTK_MENU_SHELL(font_menu), menuitem);
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1410 g_signal_connect(G_OBJECT(old), "notify::sensitive",
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1411 G_CALLBACK(button_sensitiveness_changed), menuitem);
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1412 g_signal_connect(G_OBJECT(old), "notify::visible",
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1413 G_CALLBACK(button_visibility_changed), menuitem);
19199
f06d090eedab Show formatting in the font dropdown menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19104
diff changeset
1414 gtk_container_foreach(GTK_CONTAINER(menuitem), (GtkCallback)enable_markup, NULL);
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1415 }
19076
84216ea8ddbf Move 'Reset formatting' to Font dropdown
Sean Egan <seanegan@pidgin.im>
parents: 19073
diff changeset
1416
30408
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1417 g_signal_connect(G_OBJECT(font_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
19213
e273393f4b75 The hotkeys should popup the menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19199
diff changeset
1418 g_signal_connect(G_OBJECT(font_button), "activate", G_CALLBACK(pidgin_menu_clicked), font_menu);
33139
6a4e30c1fc5d Ref some buttons so that they exist when the menu is destroyed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
1419 g_signal_connect_data(G_OBJECT(font_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate),
6a4e30c1fc5d Ref some buttons so that they exist when the menu is destroyed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
1420 g_object_ref(font_button), (GClosureNotify)g_object_unref, 0);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1421
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1422 /* Sep */
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1423 sep = gtk_vseparator_new();
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1424 gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1425 gtk_widget_show_all(sep);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1426
17594
837c8e6dbef7 Fix some stuff of bugs in the new toolbar.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17523
diff changeset
1427 /* Insert */
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1428 insert_button = gtk_toggle_button_new();
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1429 gtk_button_set_relief(GTK_BUTTON(insert_button), GTK_RELIEF_NONE);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1430 bbox = gtk_hbox_new(FALSE, 3);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1431 gtk_container_add(GTK_CONTAINER(insert_button), bbox);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1432 image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_INSERT, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1433 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1434 label = gtk_label_new_with_mnemonic(_("_Insert"));
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1435 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1436 gtk_box_pack_start(GTK_BOX(box), insert_button, FALSE, FALSE, 0);
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1437 gtk_widget_show_all(insert_button);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1438
17498
9e21b4e8a98d Re-did the toolbar layout to take up less room. This is what we generally agreed to on devel@. I managed to do this, amazingly, not only without breaking Pidgin plugin API compatibility, but it doesn't even add any API. This is still totally raw; I'm comitting it mostly so I can continue it easily from hmoe
Sean Egan <seanegan@pidgin.im>
parents: 17403
diff changeset
1439 insert_menu = gtk_menu_new();
19073
e2da82ea455b Clean up the font and insert menus when the imhtmltoolbar is disposed of. This fixes a leak (and the crash in #2385). Fixes #2385.
Daniel Atallah <datallah@pidgin.im>
parents: 19068
diff changeset
1440 g_object_set_data(G_OBJECT(toolbar), "insert_menu", insert_menu);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1441
18240
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1442 menuitem = gtk_menu_item_new_with_mnemonic(_("_Image"));
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1443 g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_button_clicked), toolbar->image);
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1444 gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1445 g_signal_connect(G_OBJECT(toolbar->image), "notify::sensitive",
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1446 G_CALLBACK(button_sensitiveness_changed), menuitem);
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1447 g_signal_connect(G_OBJECT(toolbar->image), "notify::visible",
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1448 G_CALLBACK(button_visibility_changed), menuitem);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1449
18240
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1450 menuitem = gtk_menu_item_new_with_mnemonic(_("_Link"));
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1451 g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_button_clicked), toolbar->link);
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1452 gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1453 g_signal_connect(G_OBJECT(toolbar->link), "notify::sensitive",
0a7d2fde749b Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18238
diff changeset
1454 G_CALLBACK(button_sensitiveness_changed), menuitem);
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1455 g_signal_connect(G_OBJECT(toolbar->link), "notify::visible",
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1456 G_CALLBACK(button_visibility_changed), menuitem);
17499
246d166626f3 disapproval of revision '9e21b4e8a98d7acd373a16a8b5d9c42ccc0f4a3d'
Sean Egan <seanegan@pidgin.im>
parents: 17498
diff changeset
1457
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
1458 menuitem = gtk_menu_item_new_with_mnemonic(_("_Horizontal rule"));
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
1459 g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(insert_hr_cb), toolbar);
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
1460 gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24275
diff changeset
1461 toolbar->insert_hr = menuitem;
19647
5d8cf24e5ce9 Add horizontal rules and strikethroughs to the toolbar
Sean Egan <seanegan@pidgin.im>
parents: 19213
diff changeset
1462
30408
df51a0281cde Do not trigger the formatting toolbar buttons on right-click.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29662
diff changeset
1463 g_signal_connect(G_OBJECT(insert_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
19213
e273393f4b75 The hotkeys should popup the menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19199
diff changeset
1464 g_signal_connect(G_OBJECT(insert_button), "activate", G_CALLBACK(pidgin_menu_clicked), insert_menu);
33139
6a4e30c1fc5d Ref some buttons so that they exist when the menu is destroyed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
1465 g_signal_connect_data(G_OBJECT(insert_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate),
6a4e30c1fc5d Ref some buttons so that they exist when the menu is destroyed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
1466 g_object_ref(insert_button), (GClosureNotify)g_object_unref, 0);
8427
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1467 toolbar->sml = NULL;
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24275
diff changeset
1468
20328
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1469 /* Sep */
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1470 sep = gtk_vseparator_new();
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1471 gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1472 gtk_widget_show_all(sep);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1473
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1474 /* Smiley */
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1475 smiley_button = gtk_button_new();
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1476 gtk_button_set_relief(GTK_BUTTON(smiley_button), GTK_RELIEF_NONE);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1477 bbox = gtk_hbox_new(FALSE, 3);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1478 gtk_container_add(GTK_CONTAINER(smiley_button), bbox);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1479 image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SMILEY, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1480 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
20387
9e612e1fbc03 Exclaim
Sean Egan <seanegan@pidgin.im>
parents: 20330
diff changeset
1481 label = gtk_label_new_with_mnemonic(_("_Smile!"));
20328
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1482 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1483 gtk_box_pack_start(GTK_BOX(box), smiley_button, FALSE, FALSE, 0);
31309
eea56be9e0eb Fix clicking on buttons in formatting toolbar so they don't try (and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 31294
diff changeset
1484 g_signal_connect(G_OBJECT(smiley_button), "button-press-event", G_CALLBACK(gtk_imhtmltoolbar_popup_menu), toolbar);
20328
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1485 g_signal_connect_swapped(G_OBJECT(smiley_button), "clicked", G_CALLBACK(gtk_button_clicked), toolbar->smiley);
ebb754aae698 special case smileys in the toolbar. Fixes #2668 I'll need a new icon from Hylke
Sean Egan <seanegan@pidgin.im>
parents: 20075
diff changeset
1486 gtk_widget_show_all(smiley_button);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1487
24457
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1488 /* Sep */
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1489 sep = gtk_vseparator_new();
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1490 gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1491 gtk_widget_show_all(sep);
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1492
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1493 /* Attention */
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1494 attention_button = gtk_button_new();
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1495 gtk_button_set_relief(GTK_BUTTON(attention_button), GTK_RELIEF_NONE);
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1496 bbox = gtk_hbox_new(FALSE, 3);
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1497 gtk_container_add(GTK_CONTAINER(attention_button), bbox);
30490
491fa75d3184 Compile.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30489
diff changeset
1498 image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION,
24457
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1499 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1500 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1501 label = gtk_label_new_with_mnemonic(_("_Attention!"));
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1502 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1503 gtk_box_pack_start(GTK_BOX(box), attention_button, FALSE, FALSE, 0);
30490
491fa75d3184 Compile.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30489
diff changeset
1504 g_signal_connect_swapped(G_OBJECT(attention_button), "clicked",
32699
09ff5997da90 Move the Attention toolbar button into the GtkIMHtmlToolbar struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32698
diff changeset
1505 G_CALLBACK(gtk_button_clicked), toolbar->attention);
24457
adbbdb0532b0 Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents: 24275
diff changeset
1506 gtk_widget_show_all(attention_button);
30490
491fa75d3184 Compile.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30489
diff changeset
1507
32699
09ff5997da90 Move the Attention toolbar button into the GtkIMHtmlToolbar struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32698
diff changeset
1508 g_signal_connect(G_OBJECT(toolbar->attention), "notify::sensitive",
25923
dc9e920cef05 Added connection flag ALLOW_ATTENTION
Marcus Lundblad <malu@pidgin.im>
parents: 25922
diff changeset
1509 G_CALLBACK(button_sensitiveness_changed), attention_button);
32699
09ff5997da90 Move the Attention toolbar button into the GtkIMHtmlToolbar struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32698
diff changeset
1510 g_signal_connect(G_OBJECT(toolbar->attention), "notify::visible",
30488
48928cd5e79e Add notify::visibilty handlers for the 'lean' GtkIMHtmlToolbar,
Paul Aurich <darkrain42@pidgin.im>
parents: 30485
diff changeset
1511 G_CALLBACK(button_visibility_changed), attention_button);
25923
dc9e920cef05 Added connection flag ALLOW_ATTENTION
Marcus Lundblad <malu@pidgin.im>
parents: 25922
diff changeset
1512
25936
e7c4d9db2ce6 Gray out attention toolbar button when creating the toolbar.
Marcus Lundblad <malu@pidgin.im>
parents: 25927
diff changeset
1513 /* set attention button to be greyed out until we get a conversation */
32699
09ff5997da90 Move the Attention toolbar button into the GtkIMHtmlToolbar struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32698
diff changeset
1514 gtk_widget_set_sensitive(toolbar->attention, FALSE);
30490
491fa75d3184 Compile.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 30489
diff changeset
1515
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1516 gtk_box_pack_start(GTK_BOX(hbox), box, FALSE, FALSE, 0);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1517 g_object_set_data(G_OBJECT(hbox), "lean-view", box);
22218
32ffd628be85 Show the grouped items initially. This fixes the issues with the size of the entry box in the conversation windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22099
diff changeset
1518 gtk_widget_show(box);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1519
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1520 purple_prefs_connect_callback(toolbar, PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1521 imhtmltoolbar_view_pref_changed, toolbar);
21888
c59f2fb04c7c Show either the grouped xor the ungrouped items.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21764
diff changeset
1522 g_signal_connect_data(G_OBJECT(toolbar), "realize",
c59f2fb04c7c Show either the grouped xor the ungrouped items.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21764
diff changeset
1523 G_CALLBACK(purple_prefs_trigger_callback), PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
c59f2fb04c7c Show either the grouped xor the ungrouped items.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21764
diff changeset
1524 NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1525
19978
3761c1b17eb9 Fix from fmoo so that the imhtml toolbar appears right on the MS-Windows theme (and probably other themes too).
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
1526 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event), FALSE);
3761c1b17eb9 Fix from fmoo so that the imhtml toolbar appears right on the MS-Windows theme (and probably other themes too).
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
1527
19761
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1528 gtk_widget_add_events(event, GDK_BUTTON_PRESS_MASK);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1529 gtk_box_pack_start(GTK_BOX(hbox), event, TRUE, TRUE, 0);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1530 g_signal_connect(G_OBJECT(event), "button-press-event", G_CALLBACK(gtk_imhtmltoolbar_popup_menu), toolbar);
a9f07315cf37 Add a 'Group Items'/'Ungroup Items' context menu for the toolbar in the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19719
diff changeset
1531 gtk_widget_show(event);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1532 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1533
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1534 GtkWidget *gtk_imhtmltoolbar_new()
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1535 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1536 return GTK_WIDGET(g_object_new(gtk_imhtmltoolbar_get_type(), NULL));
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1537 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1538
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1539 GType gtk_imhtmltoolbar_get_type()
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1540 {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1541 static GType imhtmltoolbar_type = 0;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1542
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1543 if (!imhtmltoolbar_type) {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1544 static const GTypeInfo imhtmltoolbar_info = {
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1545 sizeof(GtkIMHtmlToolbarClass),
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1546 NULL,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1547 NULL,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1548 (GClassInitFunc) gtk_imhtmltoolbar_class_init,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1549 NULL,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1550 NULL,
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1551 sizeof (GtkIMHtmlToolbar),
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1552 0,
12600
7ecd4441fdc7 [gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents: 11862
diff changeset
1553 (GInstanceInitFunc) gtk_imhtmltoolbar_init,
7ecd4441fdc7 [gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents: 11862
diff changeset
1554 NULL
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1555 };
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1556
10080
d562573fff16 [gaim-migrate @ 11062]
Sean Egan <seanegan@pidgin.im>
parents: 9971
diff changeset
1557 imhtmltoolbar_type = g_type_register_static(GTK_TYPE_HBOX,
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1558 "GtkIMHtmlToolbar", &imhtmltoolbar_info, 0);
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1559 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1560
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1561 return imhtmltoolbar_type;
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1562 }
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1563
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1564
8324
3bb4ba19837d [gaim-migrate @ 9048]
Christian Hammond <chipx86@chipx86.com>
parents: 8322
diff changeset
1565 void gtk_imhtmltoolbar_attach(GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml)
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1566 {
8788
a13634443a38 [gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents: 8785
diff changeset
1567 GtkIMHtmlButtons buttons;
8481
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
1568
8325
bb6ed75fcec2 [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1569 g_return_if_fail(toolbar != NULL);
bb6ed75fcec2 [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1570 g_return_if_fail(GTK_IS_IMHTMLTOOLBAR(toolbar));
bb6ed75fcec2 [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1571 g_return_if_fail(imhtml != NULL);
bb6ed75fcec2 [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1572 g_return_if_fail(GTK_IS_IMHTML(imhtml));
bb6ed75fcec2 [gaim-migrate @ 9049]
Christian Hammond <chipx86@chipx86.com>
parents: 8324
diff changeset
1573
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1574 toolbar->imhtml = imhtml;
8506
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1575 g_signal_connect(G_OBJECT(imhtml), "format_buttons_update", G_CALLBACK(update_buttons_cb), toolbar);
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1576 g_signal_connect_after(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar);
11275
cdcc651d7ecd [gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents: 11271
diff changeset
1577 g_signal_connect_after(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(update_format_cb), toolbar);
8506
76ce3a78b130 [gaim-migrate @ 9242]
Gary Kramlich <grim@pidgin.im>
parents: 8481
diff changeset
1578 g_signal_connect(G_OBJECT(imhtml), "format_function_update", G_CALLBACK(update_format_cb), toolbar);
8516
a29b503cdfa0 [gaim-migrate @ 9254]
Gary Kramlich <grim@pidgin.im>
parents: 8506
diff changeset
1579 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", G_CALLBACK(mark_set_cb), toolbar);
8481
7a9eb76e8eee [gaim-migrate @ 9214]
Gary Kramlich <grim@pidgin.im>
parents: 8456
diff changeset
1580
8788
a13634443a38 [gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents: 8785
diff changeset
1581 buttons = gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml));
8807
128d3dae0196 [gaim-migrate @ 9569]
Jon Oberheide
parents: 8788
diff changeset
1582 update_buttons_cb(GTK_IMHTML(imhtml), buttons, toolbar);
11267
78f1eb5b3d6e [gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents: 11243
diff changeset
1583 update_buttons(toolbar);
8317
fd4cf67705df [gaim-migrate @ 9041]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
1584 }
8427
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1585
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1586 void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id)
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1587 {
14097
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 13539
diff changeset
1588 g_free(toolbar->sml);
8427
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1589 toolbar->sml = g_strdup(proto_id);
b99f5085af0a [gaim-migrate @ 9157]
Sean Egan <seanegan@pidgin.im>
parents: 8420
diff changeset
1590 }
25922
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
1591
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
1592 void gtk_imhtmltoolbar_switch_active_conversation(GtkIMHtmlToolbar *toolbar,
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
1593 PurpleConversation *conv)
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
1594 {
32698
154e4a2a6287 Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31321
diff changeset
1595 PurpleConnection *gc = purple_conversation_get_connection(conv);
25924
0bbcae5e02d3 Removed _ALLOW_ATTENTION from connection flags
Marcus Lundblad <malu@pidgin.im>
parents: 25923
diff changeset
1596 PurplePlugin *prpl = purple_connection_get_prpl(gc);
29482
eef3bb59b723 Temporary workaround to not break ABI, to allow this in for 2.7.0
Marcus Lundblad <malu@pidgin.im>
parents: 28573
diff changeset
1597
eef3bb59b723 Temporary workaround to not break ABI, to allow this in for 2.7.0
Marcus Lundblad <malu@pidgin.im>
parents: 28573
diff changeset
1598 g_object_set_data(G_OBJECT(toolbar), "active_conv", conv);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30706
diff changeset
1599
25924
0bbcae5e02d3 Removed _ALLOW_ATTENTION from connection flags
Marcus Lundblad <malu@pidgin.im>
parents: 25923
diff changeset
1600 /* gray out attention button on protocols that don't support it
0bbcae5e02d3 Removed _ALLOW_ATTENTION from connection flags
Marcus Lundblad <malu@pidgin.im>
parents: 25923
diff changeset
1601 for the time being it is always disabled for chats */
32699
09ff5997da90 Move the Attention toolbar button into the GtkIMHtmlToolbar struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32698
diff changeset
1602 gtk_widget_set_sensitive(toolbar->attention,
34662
f14347f38e3b Refactor the remaining pidgin to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 33683
diff changeset
1603 conv && prpl && PURPLE_IS_IM_CONVERSATION(conv) &&
25926
b42c35950df5 NULL-check for conversation when updating attention button
Marcus Lundblad <malu@pidgin.im>
parents: 25925
diff changeset
1604 PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention != NULL);
25922
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
1605 }
0b83a033abd6 Added active conversation on GtkIMHtmlToolbar
Marcus Lundblad <malu@pidgin.im>
parents: 25920
diff changeset
1606

mercurial