annotate src/gtkimhtml.c @ 9096:84dda5b0a3a8

[gaim-migrate @ 9873] updated committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 27 May 2004 23:40:39 +0000
parents f06013ff80d9
children a9f97d5258f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * GtkIMHtml
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8026
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8026
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8026
diff changeset
6 * source distribution.
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * (at your option) any later version.
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * GNU General Public License for more details.
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 */
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
24 #ifdef HAVE_CONFIG_H
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
25 #include <config.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
26 #endif
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
27 #include "debug.h"
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
28 #include "util.h"
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "gtkimhtml.h"
7358
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
30 #include "gtksourceiter.h"
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <gtk/gtk.h>
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
32 #include <glib/gerror.h>
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
33 #include <gdk/gdkkeysyms.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <stdio.h>
4629
86fd0f6eaa1a [gaim-migrate @ 4920]
Mark Doliner <mark@kingant.net>
parents: 4612
diff changeset
37 #include <stdlib.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include <math.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
39 #ifdef HAVE_LANGINFO_CODESET
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
40 #include <langinfo.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
41 #include <locale.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
42 #endif
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
43 #ifdef _WIN32
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
44 #include <windows.h>
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
45 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
47 #ifdef ENABLE_NLS
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
48 # include <libintl.h>
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
49 # define _(x) gettext(x)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
50 # ifdef gettext_noop
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
51 # define N_(String) gettext_noop (String)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
52 # else
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
53 # define N_(String) (String)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
54 # endif
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
55 #else
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
56 # define N_(String) (String)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
57 # define _(x) (x)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
58 #endif
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
59
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
60 #include <pango/pango-font.h>
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
61
5105
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
62 /* GTK+ < 2.2.2 hack, see ui.h for details. */
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
63 #ifndef GTK_WRAP_WORD_CHAR
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
64 #define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
65 #endif
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
66
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
67 #define TOOLTIP_TIMEOUT 500
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
68
8786
f3d063680a45 [gaim-migrate @ 9548]
Ethan Blanton <elb@pidgin.im>
parents: 8782
diff changeset
69 /* GTK+ 2.0 hack */
f3d063680a45 [gaim-migrate @ 9548]
Ethan Blanton <elb@pidgin.im>
parents: 8782
diff changeset
70 #if (!GTK_CHECK_VERSION(2,2,0))
f3d063680a45 [gaim-migrate @ 9548]
Ethan Blanton <elb@pidgin.im>
parents: 8782
diff changeset
71 #define gtk_widget_get_clipboard(x, y) gtk_clipboard_get(y)
f3d063680a45 [gaim-migrate @ 9548]
Ethan Blanton <elb@pidgin.im>
parents: 8782
diff changeset
72 #endif
f3d063680a45 [gaim-migrate @ 9548]
Ethan Blanton <elb@pidgin.im>
parents: 8782
diff changeset
73
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
74 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
75 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml);
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
76 static gboolean gtk_imhtml_is_amp_escape (const gchar *string, gchar **replace, gint *length);
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
77 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter);
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
78 static void gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
79 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml);
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
80 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
81 static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
82 static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
83
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
84 /* POINT_SIZE converts from AIM font sizes to point sizes. It probably should be redone in such a
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
85 * way that it base the sizes off the default font size rather than using arbitrary font sizes. */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
86 #define MAX_FONT_SIZE 7
5367
fc0441fbf159 [gaim-migrate @ 5743]
Luke Schierer <lschiere@pidgin.im>
parents: 5293
diff changeset
87 #define POINT_SIZE(x) (options & GTK_IMHTML_USE_POINTSIZE ? x : _point_sizes [MIN ((x), MAX_FONT_SIZE) - 1])
8380
4a5b36510665 [gaim-migrate @ 9108]
Sean Egan <seanegan@gmail.com>
parents: 8367
diff changeset
88 static gdouble _point_sizes [] = { .69444444, .8333333, 1, 1.2, 1.44, 1.728, 2.0736};
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
89
8498
0a9b591278bc [gaim-migrate @ 9234]
Sean Egan <seanegan@gmail.com>
parents: 8497
diff changeset
90 enum {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
91 TARGET_HTML,
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
92 TARGET_UTF8_STRING,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
93 TARGET_COMPOUND_TEXT,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
94 TARGET_STRING,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
95 TARGET_TEXT
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
96 };
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
97
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
98 enum {
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
99 DRAG_URL
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
100 };
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
101
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
102 enum {
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
103 URL_CLICKED,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
104 BUTTONS_UPDATE,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
105 TOGGLE_FORMAT,
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
106 CLEAR_FORMAT,
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
107 UPDATE_FORMAT,
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
108 LAST_SIGNAL
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
109 };
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
110 static guint signals [LAST_SIGNAL] = { 0 };
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
111
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
112 GtkTargetEntry selection_targets[] = {
8566
6eb60b70491e [gaim-migrate @ 9313]
Sean Egan <seanegan@gmail.com>
parents: 8548
diff changeset
113 { "text/html", 0, TARGET_HTML },
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
114 { "UTF8_STRING", 0, TARGET_UTF8_STRING },
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
115 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT },
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
116 { "STRING", 0, TARGET_STRING },
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
117 { "TEXT", 0, TARGET_TEXT}};
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
118
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
119 GtkTargetEntry link_drag_drop_targets[] = {
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
120 {"x-url/ftp", 0, DRAG_URL},
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
121 {"x-url/http", 0, DRAG_URL},
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
122 {"text/uri-list", 0, DRAG_URL},
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
123 {"_NETSCAPE_URL", 0, DRAG_URL}};
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
124
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
125 #ifdef _WIN32
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
126 /* Win32 clipboard format value, and functions to convert back and
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
127 * forth between HTML and the clipboard format.
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
128 */
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
129 static UINT win_html_fmt;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
130
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
131 static gchar *
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
132 clipboard_win32_to_html(char *clipboard) {
8693
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
133 const char *begin, *end;
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
134 gchar *html;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
135
8693
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
136 begin = strstr(clipboard, "<!--StartFragment");
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
137 while(*begin++ != '>');
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
138 end = strstr(clipboard, "<!--EndFragment");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
139 html = g_strstrip(g_strndup(begin, (end ? (end - begin) : strlen(begin))));
8707
4c7bc4b0f190 [gaim-migrate @ 9460]
Luke Schierer <lschiere@pidgin.im>
parents: 8698
diff changeset
140 return html;
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
141 }
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
142
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
143 static gchar *
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
144 clipboard_html_to_win32(char *html) {
8693
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
145 int length;
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
146 gchar *ret;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
147 GString *clipboard;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
148
8693
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
149 if (html == NULL)
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
150 return NULL;
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
151
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
152 length = strlen(html);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
153 clipboard = g_string_new ("Version:0.9\r\n");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
154 g_string_append(clipboard, "StartHTML:0000000105\r\n");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
155 g_string_append(clipboard, g_strdup_printf("EndHTML:%010d\r\n", 143 + length));
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
156 g_string_append(clipboard, "StartFragment:0000000105\r\n");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
157 g_string_append(clipboard, g_strdup_printf("EndFragment:%010d\r\n", 143 + length));
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
158 g_string_append(clipboard, "<!--StartFragment-->");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
159 g_string_append(clipboard, html);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
160 g_string_append(clipboard, "<!--EndFragment-->");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
161 ret = clipboard->str;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
162 g_string_free(clipboard, FALSE);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
163 return ret;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
164 }
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
165 #endif
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
166
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
167 static GtkSmileyTree*
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
168 gtk_smiley_tree_new ()
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
169 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
170 return g_new0 (GtkSmileyTree, 1);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
171 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
172
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
173 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
174 gtk_smiley_tree_insert (GtkSmileyTree *tree,
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
175 GtkIMHtmlSmiley *smiley)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
176 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
177 GtkSmileyTree *t = tree;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
178 const gchar *x = smiley->smile;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
179
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
180 if (!strlen (x))
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
181 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
182
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
183 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
184 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
185 gint index;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
186
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
187 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
188 t->values = g_string_new ("");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
189
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
190 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
191 if (!pos) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
192 t->values = g_string_append_c (t->values, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
193 index = t->values->len - 1;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
194 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
195 t->children [index] = g_new0 (GtkSmileyTree, 1);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
196 } else
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7384
diff changeset
197 index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
198
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
199 t = t->children [index];
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
200
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
201 x++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
202 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
203
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
204 t->image = smiley;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
205 }
4041
3a36ec242415 [gaim-migrate @ 4249]
Sean Egan <seanegan@gmail.com>
parents: 4032
diff changeset
206
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
207
4264
f1876640e568 [gaim-migrate @ 4515]
Sean Egan <seanegan@gmail.com>
parents: 4263
diff changeset
208 void gtk_smiley_tree_destroy (GtkSmileyTree *tree)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
209 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
210 GSList *list = g_slist_append (NULL, tree);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
211
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
212 while (list) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
213 GtkSmileyTree *t = list->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
214 gint i;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
215 list = g_slist_remove(list, t);
7384
dc573236dc8b [gaim-migrate @ 7979]
Nathan Walp <nwalp@pidgin.im>
parents: 7371
diff changeset
216 if (t && t->values) {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
217 for (i = 0; i < t->values->len; i++)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
218 list = g_slist_append (list, t->children [i]);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
219 g_string_free (t->values, TRUE);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
220 g_free (t->children);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
221 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
222 g_free (t);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
223 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
224 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
225
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
226 static gboolean gtk_size_allocate_cb(GtkIMHtml *widget, GtkAllocation *alloc, gpointer user_data)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
227 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
228 GdkRectangle rect;
8726
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
229 int xminus;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
230
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
231 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
232 if(widget->old_rect.width != rect.width || widget->old_rect.height != rect.height){
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
233 GList *iter = GTK_IMHTML(widget)->scalables;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
234
8726
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
235 xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) +
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
236 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget));
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
237
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
238 while(iter){
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
239 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(iter->data);
8726
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
240 scale->scale(scale, rect.width - xminus, rect.height);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
241
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
242 iter = iter->next;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
243 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
244 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
245
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
246 widget->old_rect = rect;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
247 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
248 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
249
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
250 static gint
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
251 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
252 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
253 PangoLayout *layout;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
254
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
255 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
256
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
257 layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
258
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
259 gtk_paint_flat_box (imhtml->tip_window->style, imhtml->tip_window->window,
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
260 GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window,
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
261 "tooltip", 0, 0, -1, -1);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
262
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
263 gtk_paint_layout (imhtml->tip_window->style, imhtml->tip_window->window, GTK_STATE_NORMAL,
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
264 FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
265
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
266 g_object_unref(layout);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
267 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
268 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
269
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
270 static gint
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
271 gtk_imhtml_tip (gpointer data)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
272 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
273 GtkIMHtml *imhtml = data;
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
274 PangoFontMetrics *font_metrics;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
275 PangoLayout *layout;
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
276 PangoFont *font;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
277
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
278 gint gap, x, y, h, w, scr_w, baseline_skip;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
279
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
280 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
281
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
282 if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
283 imhtml->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
284 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
285 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
286
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
287 if (imhtml->tip_window){
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
288 gtk_widget_destroy (imhtml->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
289 imhtml->tip_window = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
290 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
291
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
292 imhtml->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
293 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
294 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
295 gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
296 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips");
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
297 g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event",
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
298 G_CALLBACK (gtk_imhtml_tip_paint), imhtml);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
299
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
300 gtk_widget_ensure_style (imhtml->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
301 layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
302 font = pango_context_load_font(pango_layout_get_context(layout),
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
303 imhtml->tip_window->style->font_desc);
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
304
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
305 if (font == NULL) {
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
306 char *tmp = pango_font_description_to_string(
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
307 imhtml->tip_window->style->font_desc);
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
308
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
309 gaim_debug(GAIM_DEBUG_ERROR, "gtk_imhtml_tip",
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
310 "pango_context_load_font() couldn't load font: '%s'\n",
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
311 tmp);
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
312 g_free(tmp);
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
313
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
314 return FALSE;
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
315
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
316 }
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
317
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
318 font_metrics = pango_font_get_metrics(font, NULL);
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
319
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
320
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
321 pango_layout_get_pixel_size(layout, &scr_w, NULL);
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
322 gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) +
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
323 pango_font_metrics_get_descent(font_metrics))/ 4);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
324
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
325 if (gap < 2)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
326 gap = 2;
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
327 baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) +
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
328 pango_font_metrics_get_descent(font_metrics));
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
329 w = 8 + scr_w;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
330 h = 8 + baseline_skip;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
331
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
332 gdk_window_get_pointer (NULL, &x, &y, NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
333 if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml)))
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
334 y += GTK_WIDGET(imhtml)->allocation.y;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
335
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
336 scr_w = gdk_screen_width();
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
337
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
338 x -= ((w >> 1) + 4);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
339
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
340 if ((x + w) > scr_w)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
341 x -= (x + w) - scr_w;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
342 else if (x < 0)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
343 x = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
344
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
345 y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) +
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
346 pango_font_metrics_get_descent(font_metrics));
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
347
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
348 gtk_widget_set_size_request (imhtml->tip_window, w, h);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
349 gtk_widget_show (imhtml->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
350 gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
351
8526
2f81f6478bae [gaim-migrate @ 9265]
Luke Schierer <lschiere@pidgin.im>
parents: 8519
diff changeset
352 pango_font_metrics_unref(font_metrics);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
353 g_object_unref(layout);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
354
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
355 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
356 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
357
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
358 gboolean gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
359 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
360 GtkTextIter iter;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
361 GdkWindow *win = event->window;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
362 int x, y;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
363 char *tip = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
364 GSList *tags = NULL, *templist = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
365 gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
366 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET,
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
367 event->x, event->y, &x, &y);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
368 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
369 tags = gtk_text_iter_get_tags(&iter);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
370
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
371 templist = tags;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
372 while (templist) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
373 GtkTextTag *tag = templist->data;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
374 tip = g_object_get_data(G_OBJECT(tag), "link_url");
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
375 if (tip)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
376 break;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
377 templist = templist->next;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
378 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
379
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
380 if (GTK_IMHTML(imhtml)->tip) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
381 if ((tip == GTK_IMHTML(imhtml)->tip)) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
382 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
383 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
384 /* We've left the cell. Remove the timeout and create a new one below */
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
385 if (GTK_IMHTML(imhtml)->tip_window) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
386 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
387 GTK_IMHTML(imhtml)->tip_window = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
388 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
389 if (GTK_IMHTML(imhtml)->editable)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
390 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->text_cursor);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
391 else
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
392 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
393 if (GTK_IMHTML(imhtml)->tip_timer)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
394 g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
395 GTK_IMHTML(imhtml)->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
396 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
397
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
398 if(tip){
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
399 if (!GTK_IMHTML(imhtml)->editable)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
400 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
401 GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT,
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
402 gtk_imhtml_tip, imhtml);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
403 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
404
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
405 GTK_IMHTML(imhtml)->tip = tip;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
406 g_slist_free(tags);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
407 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
408 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
409
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
410 gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
411 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
412 /* when leaving the widget, clear any current & pending tooltips and restore the cursor */
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
413 if (GTK_IMHTML(imhtml)->tip_window) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
414 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
415 GTK_IMHTML(imhtml)->tip_window = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
416 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
417 if (GTK_IMHTML(imhtml)->tip_timer) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
418 g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
419 GTK_IMHTML(imhtml)->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
420 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
421 if (GTK_IMHTML(imhtml)->editable)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
422 gdk_window_set_cursor(event->window, GTK_IMHTML(imhtml)->text_cursor);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
423 else
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
424 gdk_window_set_cursor(event->window, GTK_IMHTML(imhtml)->arrow_cursor);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
425
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8566
diff changeset
426 /* propagate the event normally */
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
427 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
428 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
429
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
430 /*
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
431 * XXX - This should be removed eventually.
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
432 *
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
433 * This function exists to work around a gross bug in GtkTextView.
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
434 * Basically, we short circuit ctrl+a and ctrl+end because they make
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
435 * el program go boom.
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
436 *
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
437 * It's supposed to be fixed in gtk2.2. You can view the bug report at
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
438 * http://bugzilla.gnome.org/show_bug.cgi?id=107939
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
439 */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
440
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
441 /*
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
442 * I'm adding some keyboard shortcuts too.
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
443 */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
444
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
445 gboolean gtk_key_pressed_cb(GtkIMHtml *imhtml, GdkEventKey *event, gpointer data)
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
446 {
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
447 char buf[7];
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
448 buf[0] = '\0';
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
449
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
450 if (event->state & GDK_CONTROL_MASK)
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
451 switch (event->keyval) {
8539
e0f659e4323e [gaim-migrate @ 9280]
Ethan Blanton <elb@pidgin.im>
parents: 8526
diff changeset
452 #if (!GTK_CHECK_VERSION(2,2,0))
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
453 case 'a':
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
454 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
455 break;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
456
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
457 case GDK_Home:
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
458 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
459 break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
460
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
461 case GDK_End:
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
462 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
463 break;
8758
2db51720fd09 [gaim-migrate @ 9513]
Mark Doliner <mark@kingant.net>
parents: 8740
diff changeset
464 #endif /* !(Gtk+ >= 2.2.0) */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
465
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
466 case 'b': /* ctrl-b is GDK_Left, which moves backwards. */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
467 case 'B':
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
468 if (imhtml->format_functions & GTK_IMHTML_BOLD) {
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
469 if(imhtml->html_shortcuts) {
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
470 gtk_imhtml_toggle_bold(imhtml);
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
471 return TRUE;
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
472 }
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
473 }
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
474 return FALSE;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
475 break;
8654
44d6285a87af [gaim-migrate @ 9406]
Ethan Blanton <elb@pidgin.im>
parents: 8588
diff changeset
476
44d6285a87af [gaim-migrate @ 9406]
Ethan Blanton <elb@pidgin.im>
parents: 8588
diff changeset
477 #ifdef LAY_OFF_MY_FRIGGIN_KEYBINDINGS
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
478 case 'f':
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
479 case 'F':
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
480 /*set_toggle(gtkconv->toolbar.font,
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
481 !gtk_toggle_button_get_active(
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
482 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font)));*/
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
483
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
484 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
485 break;
8654
44d6285a87af [gaim-migrate @ 9406]
Ethan Blanton <elb@pidgin.im>
parents: 8588
diff changeset
486 #endif /* this doesn't even DO anything */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
487
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
488 case 'i':
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
489 case 'I':
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
490 if (imhtml->format_functions & GTK_IMHTML_ITALIC) {
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
491 if(imhtml->html_shortcuts) {
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
492 gtk_imhtml_toggle_italic(imhtml);
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
493 return TRUE;
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
494 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
495 }
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
496 return FALSE;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
497 break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
498
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
499 case 'u': /* ctrl-u is GDK_Clear, which clears the line. */
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
500 case 'U':
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
501 if (imhtml->format_functions & GTK_IMHTML_UNDERLINE) {
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
502 if(imhtml->html_shortcuts) {
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
503 gtk_imhtml_toggle_underline(imhtml);
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
504 return TRUE;
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
505 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
506 }
8466
5562e8a74c94 [gaim-migrate @ 9196]
Luke Schierer <lschiere@pidgin.im>
parents: 8457
diff changeset
507 return FALSE;
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
508 break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
509
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
510 case '-':
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
511 if (imhtml->format_functions & GTK_IMHTML_SHRINK)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
512 gtk_imhtml_font_shrink(imhtml);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
513 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
514 break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
515
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
516 case '=':
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
517 case '+':
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
518 if (imhtml->format_functions & GTK_IMHTML_GROW)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
519 gtk_imhtml_font_grow(imhtml);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
520 return TRUE;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
521 break;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
522
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
523 case '1': strcpy(buf, ":-)"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
524 case '2': strcpy(buf, ":-("); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
525 case '3': strcpy(buf, ";-)"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
526 case '4': strcpy(buf, ":-P"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
527 case '5': strcpy(buf, "=-O"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
528 case '6': strcpy(buf, ":-*"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
529 case '7': strcpy(buf, ">:o"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
530 case '8': strcpy(buf, "8-)"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
531 case '!': strcpy(buf, ":-$"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
532 case '@': strcpy(buf, ":-!"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
533 case '#': strcpy(buf, ":-["); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
534 case '$': strcpy(buf, "O:-)"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
535 case '%': strcpy(buf, ":-/"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
536 case '^': strcpy(buf, ":'("); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
537 case '&': strcpy(buf, ":-X"); break;
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
538 case '*': strcpy(buf, ":-D"); break;
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
539 }
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
540 if (*buf && imhtml->smiley_shortcuts) {
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
541 gtk_imhtml_insert_smiley(imhtml, imhtml->protocol_name, buf);
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
542 return TRUE;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
543 }
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
544 return FALSE;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
545 }
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
546
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
547 static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml)
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
548 {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
549 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
550
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
551 gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
552
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
553 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
554
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
555 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data)
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
556 {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
557 GtkWidget *menuitem;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
558
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
559 menuitem = gtk_menu_item_new_with_mnemonic(_("Pa_ste As Text"));
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
560 gtk_widget_show(menuitem);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
561 gtk_widget_set_sensitive(menuitem,
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
562 (imhtml->editable &&
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
563 gtk_clipboard_wait_is_text_available(
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
564 gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD))));
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
565 /* put it after "Paste" */
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
566 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
567
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
568 g_signal_connect(G_OBJECT(menuitem), "activate",
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
569 G_CALLBACK(paste_unformatted_cb), imhtml);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
570 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
571
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
572 static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) {
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
573 char *text;
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8758
diff changeset
574 gboolean primary;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
575 GtkTextIter start, end;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
576 GtkTextMark *sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
577 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
578
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
579 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
580 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins);
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8758
diff changeset
581 primary = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY) == clipboard;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
582
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
583 if (info == TARGET_HTML) {
8907
00138e366ef8 [gaim-migrate @ 9677]
Luke Schierer <lschiere@pidgin.im>
parents: 8890
diff changeset
584 gsize len;
8148
c06b233aa84d [gaim-migrate @ 8859]
Nathan Walp <nwalp@pidgin.im>
parents: 8128
diff changeset
585 char *selection;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
586 GString *str = g_string_new(NULL);
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
587 if (primary) {
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
588 text = gtk_imhtml_get_markup_range(imhtml, &start, &end);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
589 } else
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
590 text = imhtml->clipboard_html_string;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
591
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
592 /* Mozilla asks that we start our text/html with the Unicode byte order mark */
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
593 str = g_string_append_unichar(str, 0xfeff);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
594 str = g_string_append(str, text);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
595 str = g_string_append_unichar(str, 0x0000);
8148
c06b233aa84d [gaim-migrate @ 8859]
Nathan Walp <nwalp@pidgin.im>
parents: 8128
diff changeset
596 selection = g_convert(str->str, str->len, "UCS-2", "UTF-8", NULL, &len, NULL);
8719
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
597 gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, selection, len);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
598 g_string_free(str, TRUE);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
599 g_free(selection);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
600 } else {
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
601 if (primary) {
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
602 text = gtk_imhtml_get_text(imhtml, &start, &end);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
603 } else
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
604 text = imhtml->clipboard_text_string;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
605 gtk_selection_data_set_text(selection_data, text, strlen(text));
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
606 }
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
607 if (primary) /* This was allocated here */
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
608 g_free(text);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
609 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
610
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
611 static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml)
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
612 {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
613 GtkTextIter insert;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
614 GtkTextIter selection_bound;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
615
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
616 gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
617 gtk_text_buffer_get_mark (imhtml->text_buffer, "insert"));
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
618 gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
619 gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"));
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
620
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
621 if (!gtk_text_iter_equal (&insert, &selection_bound))
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
622 gtk_text_buffer_move_mark (imhtml->text_buffer,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
623 gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"),
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
624 &insert);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
625 }
7742
6cd69aa58253 [gaim-migrate @ 8387]
Sean Egan <seanegan@gmail.com>
parents: 7740
diff changeset
626
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
627 static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused)
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
628 {
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
629 GtkTextIter start, end;
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
630 GtkTextMark *sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
631 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
632
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
633 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
634 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
635
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
636 gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
637 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
638 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
639 (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
640
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
641 if (imhtml->clipboard_html_string) {
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
642 g_free(imhtml->clipboard_html_string);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
643 g_free(imhtml->clipboard_text_string);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
644 }
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
645
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
646 imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
647 imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
648
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
649 #ifdef _WIN32
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
650 /* We're going to still copy plain text, but let's toss the "HTML Format"
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
651 we need into the windows clipboard now as well. */
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
652 HGLOBAL hdata;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
653 gchar *clipboard = clipboard_html_to_win32(imhtml->clipboard_html_string);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
654 gchar *buffer;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
655 gint length = strlen(clipboard);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
656 if(clipboard != NULL) {
8693
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
657 OpenClipboard(NULL);
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
658 hdata = GlobalAlloc(GMEM_MOVEABLE, length);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
659 buffer = GlobalLock(hdata);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
660 memcpy(buffer, clipboard, length);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
661 GlobalUnlock(hdata);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
662 SetClipboardData(win_html_fmt, hdata);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
663 CloseClipboard();
8693
f83de0baf171 [gaim-migrate @ 9446]
Luke Schierer <lschiere@pidgin.im>
parents: 8692
diff changeset
664 g_free(clipboard);
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
665 }
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
666 #endif
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
667
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
668 g_signal_stop_emission_by_name(imhtml, "copy-clipboard");
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
669 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
670
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
671 static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused)
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
672 {
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
673 GtkTextIter start, end;
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
674 GtkTextMark *sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
675 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
676
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
677 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
678 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
679
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
680 gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
681 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
682 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
683 (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
684
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
685 if (imhtml->clipboard_html_string) {
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
686 g_free(imhtml->clipboard_html_string);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
687 g_free(imhtml->clipboard_text_string);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
688 }
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
689
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
690 imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
691 imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
692
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
693 #ifdef _WIN32
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
694 /* We're going to still copy plain text, but let's toss the "HTML Format"
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
695 we need into the windows clipboard now as well. */
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
696 HGLOBAL hdata;
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
697 gchar *clipboard = clipboard_html_to_win32(imhtml->clipboard_html_string);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
698 gchar *buffer;
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
699 gint length = strlen(clipboard);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
700 if(clipboard != NULL) {
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
701 OpenClipboard(NULL);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
702 hdata = GlobalAlloc(GMEM_MOVEABLE, length);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
703 buffer = GlobalLock(hdata);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
704 memcpy(buffer, clipboard, length);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
705 GlobalUnlock(hdata);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
706 SetClipboardData(win_html_fmt, hdata);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
707 CloseClipboard();
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
708 g_free(clipboard);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
709 }
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
710 #endif
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
711
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
712 if (imhtml->editable)
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
713 gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
714 g_signal_stop_emission_by_name(imhtml, "cut-clipboard");
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
715 }
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
716
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
717 static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext)
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
718 {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
719 GtkTextIter iter;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
720 GtkIMHtmlOptions flags = plaintext ? 0 : GTK_IMHTML_NO_NEWLINE;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
721
9028
6fd7de357672 [gaim-migrate @ 9804]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
722 if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL))
6fd7de357672 [gaim-migrate @ 9804]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
723 gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE);
6fd7de357672 [gaim-migrate @ 9804]
Tim Ringenbach <marv@pidgin.im>
parents: 9025
diff changeset
724
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
725 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer));
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
726 if (!imhtml->wbfo && !plaintext)
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
727 gtk_imhtml_close_tags(imhtml, &iter);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
728
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
729 gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
730 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
731 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer),
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
732 0, FALSE, 0.0, 0.0);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
733 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
734
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
735 static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data)
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
736 {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
737 char *tmp;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
738
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
739 if (text == NULL)
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
740 return;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
741
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
742 tmp = gaim_escape_html(text);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
743 imhtml_paste_insert(data, tmp, TRUE);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
744 g_free(tmp);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
745 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
746
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
747 static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
748 {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
749 char *text;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
750 GtkIMHtml *imhtml = data;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
751
8123
0dc9fffb1e28 [gaim-migrate @ 8827]
Mark Doliner <mark@kingant.net>
parents: 8120
diff changeset
752 if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)))
8105
42c7227d6e4d [gaim-migrate @ 8805]
Mark Doliner <mark@kingant.net>
parents: 8091
diff changeset
753 return;
42c7227d6e4d [gaim-migrate @ 8805]
Mark Doliner <mark@kingant.net>
parents: 8091
diff changeset
754
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
755 if (selection_data->length < 0) {
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
756 gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
757 return;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
758 } else {
8719
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
759 #if 0
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
760 /* Here's some debug code, for figuring out what sent to us over the clipboard. */
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
761 {
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
762 int i;
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
763
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
764 gaim_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t",
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
765 selection_data->format, selection_data->length);
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
766
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
767 for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) {
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
768 if ((i % 70) == 0)
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
769 printf("\n\t");
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
770 if (selection_data->data[i] == '\0')
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
771 printf(".");
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
772 else
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
773 printf("%c", selection_data->data[i]);
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
774 }
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
775 printf("\n");
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
776 }
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
777 #endif
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
778 text = g_malloc(selection_data->length);
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
779 memcpy(text, selection_data->data, selection_data->length);
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
780 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
781
8869
ab5a46dd132a [gaim-migrate @ 9637]
Ethan Blanton <elb@pidgin.im>
parents: 8858
diff changeset
782 if (selection_data->length >= 2 &&
ab5a46dd132a [gaim-migrate @ 9637]
Ethan Blanton <elb@pidgin.im>
parents: 8858
diff changeset
783 (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) {
ab5a46dd132a [gaim-migrate @ 9637]
Ethan Blanton <elb@pidgin.im>
parents: 8858
diff changeset
784 /* This is UCS-2 */
8909
87e171358001 [gaim-migrate @ 9679]
Luke Schierer <lschiere@pidgin.im>
parents: 8907
diff changeset
785 char *tmp;
8869
ab5a46dd132a [gaim-migrate @ 9637]
Ethan Blanton <elb@pidgin.im>
parents: 8858
diff changeset
786 char *utf8 = g_convert(text, selection_data->length, "UTF-8", "UCS-2", NULL, NULL, NULL);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
787 g_free(text);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
788 text = utf8;
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
789 if (!text) {
8869
ab5a46dd132a [gaim-migrate @ 9637]
Ethan Blanton <elb@pidgin.im>
parents: 8858
diff changeset
790 gaim_debug_warning("gtkimhtml", "g_convert from UCS-2 failed in paste_received_cb\n");
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
791 return;
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
792 }
8909
87e171358001 [gaim-migrate @ 9679]
Luke Schierer <lschiere@pidgin.im>
parents: 8907
diff changeset
793 tmp = g_utf8_next_char(text);
87e171358001 [gaim-migrate @ 9679]
Luke Schierer <lschiere@pidgin.im>
parents: 8907
diff changeset
794 memmove(text, tmp, strlen(tmp) + 1);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
795 }
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
796
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
797 if (!(*text) || !g_utf8_validate(text, -1, NULL)) {
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
798 gaim_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n");
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
799 g_free(text);
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
800 return;
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
801 }
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
802
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
803 imhtml_paste_insert(imhtml, text, FALSE);
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
804 g_free(text);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
805 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
806
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
807 static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
808 {
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
809 #ifdef _WIN32
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
810 /* If we're on windows, let's see if we can get data from the HTML Format
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
811 clipboard before we try to paste from the GTK buffer */
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
812 HGLOBAL hdata;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
813 DWORD err;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
814 char *buffer;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
815 char *text;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
816
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
817 if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)))
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
818 return;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
819
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
820 if (IsClipboardFormatAvailable(win_html_fmt)) {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
821 OpenClipboard(NULL);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
822 hdata = GetClipboardData(win_html_fmt);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
823 if (hdata == NULL) {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
824 err = GetLastError();
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
825 gaim_debug_info("html clipboard", "error number %u! See http://msdn.microsoft.com/library/en-us/debug/base/system_error_codes.asp\n", err);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
826 CloseClipboard();
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
827 return;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
828 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
829 buffer = GlobalLock(hdata);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
830 if (buffer == NULL) {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
831 err = GetLastError();
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
832 gaim_debug_info("html clipboard", "error number %u! See http://msdn.microsoft.com/library/en-us/debug/base/system_error_codes.asp\n", err);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
833 CloseClipboard();
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
834 return;
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
835 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
836 text = clipboard_win32_to_html(buffer);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
837 GlobalUnlock(hdata);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
838 CloseClipboard();
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
839
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
840 imhtml_paste_insert(imhtml, text, FALSE);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
841 g_free(text);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
842 } else {
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
843 #endif
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
844 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
845 gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE),
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
846 paste_received_cb, imhtml);
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
847 #ifdef _WIN32
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
848 }
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
849 #endif
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
850 g_signal_stop_emission_by_name(imhtml, "paste-clipboard");
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
851 }
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
852
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
853 static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
854 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
855 gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
856 gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
857
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
858 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
859
8740
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
860 static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused)
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
861 {
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
862 gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer,
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
863 gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY));
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
864 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
865
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
866 static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
867 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
868 if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
869 gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
870 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
871 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
872 (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
873 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
874 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
875
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
876 static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused)
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
877 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
878 if (event->button == 2) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
879 int x, y;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
880 GtkTextIter iter;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
881 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
882
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
883 if (!imhtml->editable)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
884 return FALSE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
885
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
886 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
887 GTK_TEXT_WINDOW_TEXT,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
888 event->x,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
889 event->y,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
890 &x,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
891 &y);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
892 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
893 gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
894
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
895 gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
896 paste_received_cb, imhtml);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
897
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
898 return TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
899 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
900
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
901 return FALSE;
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
902 }
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
903
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
904 static GtkTextViewClass *parent_class = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
905
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
906 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
907 gtk_imhtml_finalize (GObject *object)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
908 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
909 GtkIMHtml *imhtml = GTK_IMHTML(object);
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
910 GList *scalables;
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
911 GSList *l;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
912
4138
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
913 g_hash_table_destroy(imhtml->smiley_data);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
914 gtk_smiley_tree_destroy(imhtml->default_smilies);
4138
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
915 gdk_cursor_unref(imhtml->hand_cursor);
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
916 gdk_cursor_unref(imhtml->arrow_cursor);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
917 gdk_cursor_unref(imhtml->text_cursor);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
918
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
919 if(imhtml->tip_window){
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
920 gtk_widget_destroy(imhtml->tip_window);
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
921 }
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
922 if(imhtml->tip_timer)
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
923 gtk_timeout_remove(imhtml->tip_timer);
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
924
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
925 for(scalables = imhtml->scalables; scalables; scalables = scalables->next) {
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
926 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(scalables->data);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
927 scale->free(scale);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
928 }
7991
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
929
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
930 for (l = imhtml->im_images; l; l = l->next) {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
931 int id;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
932 id = GPOINTER_TO_INT(l->data);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
933 if (imhtml->funcs->image_unref)
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
934 imhtml->funcs->image_unref(id);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
935 }
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
936
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
937 if (imhtml->clipboard_text_string) {
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
938 g_free(imhtml->clipboard_text_string);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
939 g_free(imhtml->clipboard_html_string);
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
940 }
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
941
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
942 g_list_free(imhtml->scalables);
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
943 g_slist_free(imhtml->im_images);
9029
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
944 if (imhtml->protocol_name)
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
945 g_free(imhtml->protocol_name);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
946 G_OBJECT_CLASS(parent_class)->finalize (object);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
947 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
949 /* Boring GTK stuff */
8519
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
950 static void gtk_imhtml_class_init (GtkIMHtmlClass *klass)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 {
9007
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
952 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
953 GtkObjectClass *object_class;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
954 GObjectClass *gobject_class;
8519
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
955 object_class = (GtkObjectClass*) klass;
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
956 gobject_class = (GObjectClass*) klass;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
957 parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
958 signals[URL_CLICKED] = g_signal_new("url_clicked",
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
959 G_TYPE_FROM_CLASS(gobject_class),
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
960 G_SIGNAL_RUN_FIRST,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
961 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked),
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
962 NULL,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
963 0,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
964 g_cclosure_marshal_VOID__POINTER,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
965 G_TYPE_NONE, 1,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
966 G_TYPE_POINTER);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
967 signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update",
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
968 G_TYPE_FROM_CLASS(gobject_class),
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
969 G_SIGNAL_RUN_FIRST,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
970 G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update),
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
971 NULL,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
972 0,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
973 g_cclosure_marshal_VOID__POINTER,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
974 G_TYPE_NONE, 1,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
975 G_TYPE_INT);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
976 signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle",
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
977 G_TYPE_FROM_CLASS(gobject_class),
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
978 G_SIGNAL_RUN_FIRST,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
979 G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format),
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
980 NULL,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
981 0,
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
982 g_cclosure_marshal_VOID__POINTER,
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
983 G_TYPE_NONE, 1,
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
984 G_TYPE_INT);
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
985 signals[CLEAR_FORMAT] = g_signal_new("format_function_clear",
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
986 G_TYPE_FROM_CLASS(gobject_class),
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
987 G_SIGNAL_RUN_FIRST,
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
988 G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format),
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
989 NULL,
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
990 0,
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
991 g_cclosure_marshal_VOID__VOID,
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
992 G_TYPE_NONE, 0);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
993 signals[UPDATE_FORMAT] = g_signal_new("format_function_update",
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
994 G_TYPE_FROM_CLASS(gobject_class),
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
995 G_SIGNAL_RUN_FIRST,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
996 G_STRUCT_OFFSET(GtkIMHtmlClass, update_format),
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
997 NULL,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
998 0,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
999 g_cclosure_marshal_VOID__VOID,
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
1000 G_TYPE_NONE, 0);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1001 gobject_class->finalize = gtk_imhtml_finalize;
9007
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
1002
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
1003 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color",
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
1004 _("Hyperlink color"),
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
1005 _("Color to draw hyperlinks."),
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
1006 GDK_TYPE_COLOR, G_PARAM_READABLE));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1009 static void gtk_imhtml_init (GtkIMHtml *imhtml)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1011 GtkTextIter iter;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1012 imhtml->text_buffer = gtk_text_buffer_new(NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1013 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1014 imhtml->scrollpoint = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, FALSE);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1015 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer);
5105
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
1016 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1017 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1018 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1019 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1020 /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1021 /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1022
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1023 /* These tags will be used often and can be reused--we create them on init and then apply them by name
8932
849507541e86 [gaim-migrate @ 9702]
Tim Ringenbach <marv@pidgin.im>
parents: 8931
diff changeset
1024 * other tags (color, size, face, etc.) will have to be created and applied dynamically
849507541e86 [gaim-migrate @ 9702]
Tim Ringenbach <marv@pidgin.im>
parents: 8931
diff changeset
1025 * Note that even though we created STRIKE, SUB, SUP, and PRE tags here, we don't really
849507541e86 [gaim-migrate @ 9702]
Tim Ringenbach <marv@pidgin.im>
parents: 8931
diff changeset
1026 * apply them anywhere yet. */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1027 gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1028 gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1029 gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1030 gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1031 gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1032 gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1033 gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL);
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
1034 gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1035
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1036 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1037 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1038 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1039 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1040
6124
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
1041 imhtml->show_comments = TRUE;
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1042
8740
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
1043 imhtml->zoom = 1.0;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
1044 imhtml->original_fsize = 0;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
1045
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
1046 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal,
4902
0bbccc88bc67 [gaim-migrate @ 5236]
Nathan Walp <nwalp@pidgin.im>
parents: 4895
diff changeset
1047 g_free, (GDestroyNotify)gtk_smiley_tree_destroy);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1048 imhtml->default_smilies = gtk_smiley_tree_new();
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1049
4944
5fe846b7603f [gaim-migrate @ 5278]
Sean Egan <seanegan@gmail.com>
parents: 4926
diff changeset
1050 g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL);
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1051 g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL);
4944
5fe846b7603f [gaim-migrate @ 5278]
Sean Egan <seanegan@gmail.com>
parents: 4926
diff changeset
1052 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL);
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
1053 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1054 g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1055 g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1056 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml);
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1057
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1058 gtk_drag_dest_set(GTK_WIDGET(imhtml), 0,
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1059 link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry),
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1060 GDK_ACTION_COPY);
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1061 g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml);
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1062
7353
dc35b4a42fea [gaim-migrate @ 7944]
Sean Egan <seanegan@gmail.com>
parents: 7346
diff changeset
1063 g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL);
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
1064 g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1065 g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1066 g_signal_connect_after(G_OBJECT(imhtml), "realize", G_CALLBACK(imhtml_realized_remove_primary), NULL);
8740
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
1067 g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1068
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1069 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set",
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1070 G_CALLBACK(mark_set_so_update_selection_cb), imhtml);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1071
4944
5fe846b7603f [gaim-migrate @ 5278]
Sean Egan <seanegan@gmail.com>
parents: 4926
diff changeset
1072 gtk_widget_add_events(GTK_WIDGET(imhtml), GDK_LEAVE_NOTIFY_MASK);
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1073
8681
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
1074 imhtml->clipboard_text_string = NULL;
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
1075 imhtml->clipboard_html_string = NULL;
e2e56231023c [gaim-migrate @ 9434]
Sean Egan <seanegan@gmail.com>
parents: 8677
diff changeset
1076
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1077 imhtml->tip = NULL;
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1078 imhtml->tip_timer = 0;
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1079 imhtml->tip_window = NULL;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1080
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1081 imhtml->edit.bold = FALSE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1082 imhtml->edit.italic = FALSE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1083 imhtml->edit.underline = FALSE;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1084 imhtml->edit.forecolor = NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1085 imhtml->edit.backcolor = NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1086 imhtml->edit.fontface = NULL;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1087 imhtml->edit.fontsize = 0;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1088 imhtml->edit.link = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1089
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1090
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1091 imhtml->scalables = NULL;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1092
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1093 gtk_imhtml_set_editable(imhtml, FALSE);
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
1094
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
1095 g_signal_connect(G_OBJECT(imhtml), "populate-popup",
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
1096 G_CALLBACK(hijack_menu_cb), NULL);
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
1097
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
1098 #ifdef _WIN32
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
1099 /* Register HTML Format as desired clipboard format */
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
1100 win_html_fmt = RegisterClipboardFormat("HTML Format");
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
1101 #endif
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1102 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1103
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1104 GtkWidget *gtk_imhtml_new(void *a, void *b)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1106 return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108
9037
960bb3bd9ba6 [gaim-migrate @ 9813]
Luke Schierer <lschiere@pidgin.im>
parents: 9034
diff changeset
1109 GType gtk_imhtml_get_type()
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 {
9037
960bb3bd9ba6 [gaim-migrate @ 9813]
Luke Schierer <lschiere@pidgin.im>
parents: 9034
diff changeset
1111 static GType imhtml_type = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1113 if (!imhtml_type) {
9037
960bb3bd9ba6 [gaim-migrate @ 9813]
Luke Schierer <lschiere@pidgin.im>
parents: 9034
diff changeset
1114 static const GTypeInfo imhtml_info = {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1115 sizeof(GtkIMHtmlClass),
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1116 NULL,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1117 NULL,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1118 (GClassInitFunc) gtk_imhtml_class_init,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1119 NULL,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1120 NULL,
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 sizeof (GtkIMHtml),
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1122 0,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1123 (GInstanceInitFunc) gtk_imhtml_init
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 };
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1125
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1126 imhtml_type = g_type_register_static(gtk_text_view_get_type(),
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
1127 "GtkIMHtml", &imhtml_info, 0);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1133 struct url_data {
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1134 GObject *object;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1135 gchar *url;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1136 };
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1137
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1138 static void url_data_destroy(gpointer mydata)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1139 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1140 struct url_data *data = mydata;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1141 g_object_unref(data->object);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1142 g_free(data->url);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1143 g_free(data);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1144 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1145
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1146 static void url_open(GtkWidget *w, struct url_data *data) {
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1147 if(!data) return;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1148 g_signal_emit(data->object, signals[URL_CLICKED], 0, data->url);
7988
d9e831876c28 [gaim-migrate @ 8665]
Nathan Walp <nwalp@pidgin.im>
parents: 7961
diff changeset
1149
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1150 }
5582
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
1151
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1152 static void url_copy(GtkWidget *w, gchar *url) {
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1153 GtkClipboard *clipboard;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1154
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
1155 clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_PRIMARY);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1156 gtk_clipboard_set_text(clipboard, url, -1);
5582
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
1157
8931
73223e21b943 [gaim-migrate @ 9701]
Tim Ringenbach <marv@pidgin.im>
parents: 8909
diff changeset
1158 clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_CLIPBOARD);
5582
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
1159 gtk_clipboard_set_text(clipboard, url, -1);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1160 }
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1161
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1162 /* The callback for an event on a link tag. */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1163 gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, gpointer unused) {
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1164 GdkEventButton *event_button = (GdkEventButton *) event;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1165 if (GTK_IMHTML(imhtml)->editable)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1166 return FALSE;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1167 if (event->type == GDK_BUTTON_RELEASE) {
8957
97a1f314b051 [gaim-migrate @ 9731]
Tim Ringenbach <marv@pidgin.im>
parents: 8932
diff changeset
1168 if ((event_button->button == 1) || (event_button->button == 2)) {
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1169 GtkTextIter start, end;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1170 /* we shouldn't open a URL if the user has selected something: */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1171 if (gtk_text_buffer_get_selection_bounds(
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1172 gtk_text_iter_get_buffer(arg2), &start, &end))
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1173 return FALSE;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1174
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1175 /* A link was clicked--we emit the "url_clicked" signal
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1176 * with the URL as the argument */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1177 g_object_ref(G_OBJECT(tag));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1178 g_signal_emit(imhtml, signals[URL_CLICKED], 0, g_object_get_data(G_OBJECT(tag), "link_url"));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1179 g_object_unref(G_OBJECT(tag));
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1180 return FALSE;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1181 } else if(event_button->button == 3) {
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
1182 GtkWidget *img, *item, *menu;
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1183 struct url_data *tempdata = g_new(struct url_data, 1);
5091
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1184 tempdata->object = g_object_ref(imhtml);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1185 tempdata->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url"));
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
1186
5091
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1187 /* Don't want the tooltip around if user right-clicked on link */
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1188 if (GTK_IMHTML(imhtml)->tip_window) {
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1189 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1190 GTK_IMHTML(imhtml)->tip_window = NULL;
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1191 }
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1192 if (GTK_IMHTML(imhtml)->tip_timer) {
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1193 g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1194 GTK_IMHTML(imhtml)->tip_timer = 0;
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
1195 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1196 if (GTK_IMHTML(imhtml)->editable)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1197 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1198 else
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1199 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1200 menu = gtk_menu_new();
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1201 g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", tempdata, url_data_destroy);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
1202
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1203 /* buttons and such */
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1204
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1205 if (!strncmp(tempdata->url, "mailto:", 7))
7140
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1206 {
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1207 /* Copy E-Mail Address */
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1208 img = gtk_image_new_from_stock(GTK_STOCK_COPY,
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1209 GTK_ICON_SIZE_MENU);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1210 item = gtk_image_menu_item_new_with_mnemonic(
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1211 _("_Copy E-Mail Address"));
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1212 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1213 g_signal_connect(G_OBJECT(item), "activate",
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1214 G_CALLBACK(url_copy), tempdata->url + 7);
7140
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1215 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1216 }
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1217 else
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1218 {
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1219 /* Copy Link Location */
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1220 img = gtk_image_new_from_stock(GTK_STOCK_COPY,
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1221 GTK_ICON_SIZE_MENU);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1222 item = gtk_image_menu_item_new_with_mnemonic(
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1223 _("_Copy Link Location"));
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1224 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1225 g_signal_connect(G_OBJECT(item), "activate",
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1226 G_CALLBACK(url_copy), tempdata->url);
7140
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1227 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1228
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1229 /* Open Link in Browser */
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1230 img = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO,
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1231 GTK_ICON_SIZE_MENU);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1232 item = gtk_image_menu_item_new_with_mnemonic(
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1233 _("_Open Link in Browser"));
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1234 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1235 g_signal_connect(G_OBJECT(item), "activate",
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1236 G_CALLBACK(url_open), tempdata);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1237 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1238 }
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
1239
4756
85637881b342 [gaim-migrate @ 5073]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1240
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1241 gtk_widget_show_all(menu);
4756
85637881b342 [gaim-migrate @ 5073]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1242 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
85637881b342 [gaim-migrate @ 5073]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1243 event_button->button, event_button->time);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
1244
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1245 return TRUE;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1246 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1247 }
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1248 if(event->type == GDK_BUTTON_PRESS && event_button->button == 3)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1249 return TRUE; /* Clicking the right mouse button on a link shouldn't
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1250 be caught by the regular GtkTextView menu */
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1251 else
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
1252 return FALSE; /* Let clicks go through if we didn't catch anything */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1255 static void
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1256 gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1257 GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml)
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1258 {
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1259 if(gtk_imhtml_get_editable(imhtml) && sd->data){
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1260 gchar **links;
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1261 gchar *link;
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1262
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1263 gaim_str_strip_cr(sd->data);
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1264
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1265 links = g_strsplit(sd->data, "\n", 0);
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1266 while((link = *links++) != NULL){
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1267 if(gaim_str_has_prefix(link, "http://") ||
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1268 gaim_str_has_prefix(link, "https://") ||
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1269 gaim_str_has_prefix(link, "ftp://")){
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1270 gtk_imhtml_insert_link(imhtml, gtk_text_buffer_get_insert(imhtml->text_buffer), link, link);
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1271 } else if (link=='\0') {
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
1272 /* Ignore blank lines */
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1273 } else {
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
1274 /* Special reasons, aka images being put in via other tag, etc. */
8091
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1275 }
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1276 }
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1277
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1278 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1279 } else {
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1280 gtk_drag_finish(dc, FALSE, FALSE, t);
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1281 }
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1282 }
56b74730715f [gaim-migrate @ 8790]
Sean Egan <seanegan@gmail.com>
parents: 8061
diff changeset
1283
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
1284 /* this isn't used yet
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1285 static void
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1286 gtk_smiley_tree_remove (GtkSmileyTree *tree,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1287 GtkIMHtmlSmiley *smiley)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1288 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1289 GtkSmileyTree *t = tree;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1290 const gchar *x = smiley->smile;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1291 gint len = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1292
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1293 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1294 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1295
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1296 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1297 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1298
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1299 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1300 if (pos)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1301 t = t->children [(int) pos - (int) t->values->str];
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1302 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1303 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1304
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1305 x++; len++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1306 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1307
4141
ccec4fde84f4 [gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents: 4140
diff changeset
1308 if (t->image) {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1309 t->image = NULL;
4141
ccec4fde84f4 [gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents: 4140
diff changeset
1310 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1311 }
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
1312 */
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
1313
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1314
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1315 static gint
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1316 gtk_smiley_tree_lookup (GtkSmileyTree *tree,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1317 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1318 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1319 GtkSmileyTree *t = tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1320 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1321 gint len = 0;
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1322 gchar *amp;
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1323 gint alen;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1324
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1325 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1326 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1327
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1328 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1329 break;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1330
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1331 if(*x == '&' && gtk_imhtml_is_amp_escape(x, &amp, &alen)) {
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1332 len += alen - strlen(amp);
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1333 x += alen - strlen(amp);
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1334 pos = strchr (t->values->str, *amp);
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1335 }
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1336 else
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1337 pos = strchr (t->values->str, *x);
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1338
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1339 if (pos)
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1340 t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)];
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1341 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1342 break;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1343
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1344 x++; len++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1345 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1346
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1347 if (t->image)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1348 return len;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1349
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1350 return 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1351 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1352
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1353 void
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1354 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1355 gchar *sml,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1356 GtkIMHtmlSmiley *smiley)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1357 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1358 GtkSmileyTree *tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1359 g_return_if_fail (imhtml != NULL);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1360 g_return_if_fail (GTK_IS_IMHTML (imhtml));
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1361
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1362 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1363 tree = imhtml->default_smilies;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1364 else if ((tree = g_hash_table_lookup(imhtml->smiley_data, sml))) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1365 } else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1366 tree = gtk_smiley_tree_new();
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
1367 g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1368 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1369
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1370 gtk_smiley_tree_insert (tree, smiley);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1371 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1372
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1373 static gboolean
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1374 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1375 GSList *fonts,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1376 const gchar *text,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1377 gint *len)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1378 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1379 GtkSmileyTree *tree;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1380 GtkIMHtmlFontDetail *font;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1381 char *sml = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1382
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1383 if (fonts) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1384 font = fonts->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1385 sml = font->sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1386 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1387
9029
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
1388 if (!sml)
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
1389 sml = imhtml->protocol_name;
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
1390
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
1391 if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml)))
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1392 tree = imhtml->default_smilies;
9029
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
1393
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1394 if (tree == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1395 return FALSE;
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1396
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
1397 *len = gtk_smiley_tree_lookup (tree, text);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1398 return (*len > 0);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1399 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1400
6814
782907a6ae65 [gaim-migrate @ 7354]
Christian Hammond <chipx86@chipx86.com>
parents: 6648
diff changeset
1401 GdkPixbufAnimation *
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1402 gtk_smiley_tree_image (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1403 const gchar *sml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1404 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1405 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1406 GtkSmileyTree *t;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1407 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1408 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1409 t = imhtml->default_smilies;
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1410 else
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1411 t = g_hash_table_lookup(imhtml->smiley_data, sml);
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1412
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1413
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1414 if (t == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1415 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1416
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1417 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1418 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1419
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1420 if (!t->values) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1421 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1422 }
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1423
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1424 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1425 if (pos) {
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
1426 t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)];
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1427 } else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1428 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1429 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1430 x++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1431 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1432
8890
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
1433 if (!t->image->file)
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
1434 return NULL;
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
1435
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1436 if (!t->image->icon)
6814
782907a6ae65 [gaim-migrate @ 7354]
Christian Hammond <chipx86@chipx86.com>
parents: 6648
diff changeset
1437 t->image->icon = gdk_pixbuf_animation_new_from_file(t->image->file, NULL);
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1438
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
1439 return t->image->icon;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1440 }
8890
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
1441
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1442 #define VALID_TAG(x) if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1443 *tag = g_strndup (string, strlen (x)); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1444 *len = strlen (x) + 1; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1445 return TRUE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1446 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1447 (*type)++
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1449 #define VALID_OPT_TAG(x) if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1450 const gchar *c = string + strlen (x " "); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1451 gchar e = '"'; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1452 gboolean quote = FALSE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1453 while (*c) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1454 if (*c == '"' || *c == '\'') { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1455 if (quote && (*c == e)) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1456 quote = !quote; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1457 else if (!quote) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1458 quote = !quote; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1459 e = *c; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1460 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1461 } else if (!quote && (*c == '>')) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1462 break; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1463 c++; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1464 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1465 if (*c) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1466 *tag = g_strndup (string, c - string); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1467 *len = c - string + 1; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1468 return TRUE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1469 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1470 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1471 (*type)++
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1474 static gboolean
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1475 gtk_imhtml_is_amp_escape (const gchar *string,
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1476 gchar **replace,
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1477 gint *length)
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1478 {
7287
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
1479 static char buf[7];
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1480 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1481 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1482 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1483
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1484 if (!g_ascii_strncasecmp (string, "&amp;", 5)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1485 *replace = "&";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1486 *length = 5;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1487 } else if (!g_ascii_strncasecmp (string, "&lt;", 4)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1488 *replace = "<";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1489 *length = 4;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1490 } else if (!g_ascii_strncasecmp (string, "&gt;", 4)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1491 *replace = ">";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1492 *length = 4;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1493 } else if (!g_ascii_strncasecmp (string, "&nbsp;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1494 *replace = " ";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1495 *length = 6;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1496 } else if (!g_ascii_strncasecmp (string, "&copy;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1497 *replace = "©";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1498 *length = 6;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1499 } else if (!g_ascii_strncasecmp (string, "&quot;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1500 *replace = "\"";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1501 *length = 6;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1502 } else if (!g_ascii_strncasecmp (string, "&reg;", 5)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1503 *replace = "®";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1504 *length = 5;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1505 } else if (!g_ascii_strncasecmp (string, "&apos;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1506 *replace = "\'";
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1507 *length = 6;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1508 } else if (*(string + 1) == '#') {
2022
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
1509 guint pound = 0;
3004
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 3000
diff changeset
1510 if ((sscanf (string, "&#%u;", &pound) == 1) && pound != 0) {
7287
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
1511 int buflen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1512 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1513 return FALSE;
7287
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
1514 buflen = g_unichar_to_utf8((gunichar)pound, buf);
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
1515 buf[buflen] = '\0';
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1516 *replace = buf;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1517 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1518 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1519 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1520 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1521 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1522 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1523 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1524 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1525 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1526
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1527 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1528 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
1529
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1530 static gboolean
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1531 gtk_imhtml_is_tag (const gchar *string,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1532 gchar **tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1533 gint *len,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1534 gint *type)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1535 {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1536 char *close;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1537 *type = 1;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1538
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1539
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1540 if (!(close = strchr (string, '>')))
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1541 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1542
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1543 VALID_TAG ("B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1544 VALID_TAG ("BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1545 VALID_TAG ("/B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1546 VALID_TAG ("/BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1547 VALID_TAG ("I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1548 VALID_TAG ("ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1549 VALID_TAG ("/I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1550 VALID_TAG ("/ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1551 VALID_TAG ("U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1552 VALID_TAG ("UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1553 VALID_TAG ("/U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1554 VALID_TAG ("/UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1555 VALID_TAG ("S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1556 VALID_TAG ("STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1557 VALID_TAG ("/S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1558 VALID_TAG ("/STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1559 VALID_TAG ("SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1560 VALID_TAG ("/SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1561 VALID_TAG ("SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1562 VALID_TAG ("/SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1563 VALID_TAG ("PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1564 VALID_TAG ("/PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1565 VALID_TAG ("TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1566 VALID_TAG ("/TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1567 VALID_TAG ("BR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1568 VALID_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1569 VALID_TAG ("/FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1570 VALID_TAG ("/A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1571 VALID_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1572 VALID_TAG ("/P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1573 VALID_TAG ("H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1574 VALID_TAG ("/H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1575 VALID_TAG ("HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1576 VALID_TAG ("/HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1577 VALID_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1578 VALID_TAG ("/BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1579 VALID_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1580 VALID_TAG ("HEAD");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1581 VALID_TAG ("/HEAD");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1582 VALID_TAG ("BINARY");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1583 VALID_TAG ("/BINARY");
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1584
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1585 VALID_OPT_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1586 VALID_OPT_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1587 VALID_OPT_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1588 VALID_OPT_TAG ("A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1589 VALID_OPT_TAG ("IMG");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1590 VALID_OPT_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1591 VALID_OPT_TAG ("H3");
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1592 VALID_OPT_TAG ("HTML");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1593
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1594 VALID_TAG ("CITE");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1595 VALID_TAG ("/CITE");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1596 VALID_TAG ("EM");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1597 VALID_TAG ("/EM");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1598 VALID_TAG ("STRONG");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1599 VALID_TAG ("/STRONG");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1600
5104
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1601 VALID_OPT_TAG ("SPAN");
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1602 VALID_TAG ("/SPAN");
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5118
diff changeset
1603 VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1604 VALID_TAG ("IMG");
8026
17b90334f3cc [gaim-migrate @ 8706]
Nathan Walp <nwalp@pidgin.im>
parents: 7991
diff changeset
1605 VALID_TAG("SPAN");
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1606 VALID_OPT_TAG("BR");
7988
d9e831876c28 [gaim-migrate @ 8665]
Nathan Walp <nwalp@pidgin.im>
parents: 7961
diff changeset
1607
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1608 if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) {
2954
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
1609 gchar *e = strstr (string + strlen("!--"), "-->");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1610 if (e) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1611 *len = e - string + strlen ("-->");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1612 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->"));
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1613 return TRUE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1614 }
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1615 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1616
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1617 *type = -1;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1618 *len = close - string + 1;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1619 *tag = g_strndup(string, *len - 1);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1620 return TRUE;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1621 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1622
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1623 static gchar*
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1624 gtk_imhtml_get_html_opt (gchar *tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1625 const gchar *opt)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1626 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1627 gchar *t = tag;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1628 gchar *e, *a;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1629 gchar *val;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1630 gint len;
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1631 gchar *c;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1632 GString *ret;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1633
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1634 while (g_ascii_strncasecmp (t, opt, strlen (opt))) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1635 gboolean quote = FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1636 if (*t == '\0') break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1637 while (*t && !((*t == ' ') && !quote)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1638 if (*t == '\"')
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1639 quote = ! quote;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1640 t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1641 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1642 while (*t && (*t == ' ')) t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1643 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1644
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1645 if (!g_ascii_strncasecmp (t, opt, strlen (opt))) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1646 t += strlen (opt);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1647 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1648 return NULL;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1649 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1650
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1651 if ((*t == '\"') || (*t == '\'')) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1652 e = a = ++t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1653 while (*e && (*e != *(t - 1))) e++;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1654 if (*e == '\0') {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1655 return NULL;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1656 } else
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1657 val = g_strndup(a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1658 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1659 e = a = t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1660 while (*e && !isspace ((gint) *e)) e++;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1661 val = g_strndup(a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1662 }
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1663
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1664 ret = g_string_new("");
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1665 e = val;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1666 while(*e) {
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1667 if(gtk_imhtml_is_amp_escape(e, &c, &len)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1668 ret = g_string_append(ret, c);
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1669 e += len;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1670 } else {
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1671 ret = g_string_append_c(ret, *e);
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1672 e++;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1673 }
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1674 }
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1675
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1676 g_free(val);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8566
diff changeset
1677
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8566
diff changeset
1678 return g_string_free(ret, FALSE);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1679 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1680
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1681 /* Inline CSS Support - Douglas Thrift */
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1682 static gchar*
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1683 gtk_imhtml_get_css_opt (gchar *style,
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1684 const gchar *opt)
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1685 {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1686 gchar *t = style;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1687 gchar *e, *a;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1688 gchar *val;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1689 gint len;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1690 gchar *c;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1691 GString *ret;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1692
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1693 while (g_ascii_strncasecmp (t, opt, strlen (opt))) {
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
1694 /* gboolean quote = FALSE; */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1695 if (*t == '\0') break;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1696 while (*t && !((*t == ' ') /*&& !quote*/)) {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1697 /* if (*t == '\"')
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
1698 quote = ! quote; */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1699 t++;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1700 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1701 while (*t && (*t == ' ')) t++;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1702 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1703
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1704 if (!g_ascii_strncasecmp (t, opt, strlen (opt))) {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1705 t += strlen (opt);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1706 } else {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1707 return NULL;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1708 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1709
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1710 /* if ((*t == '\"') || (*t == '\'')) {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1711 e = a = ++t;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1712 while (*e && (*e != *(t - 1))) e++;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1713 if (*e == '\0') {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1714 return NULL;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1715 } else
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1716 val = g_strndup(a, e - a);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1717 } else {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1718 e = a = t;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1719 while (*e && !isspace ((gint) *e)) e++;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1720 val = g_strndup(a, e - a);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1721 }*/
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1722
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1723 e = a = t;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1724 while (*e && *e != ';') e++;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1725 val = g_strndup(a, e - a);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1726
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1727 ret = g_string_new("");
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1728 e = val;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1729 while(*e) {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1730 if(gtk_imhtml_is_amp_escape(e, &c, &len)) {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1731 ret = g_string_append(ret, c);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1732 e += len;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1733 } else {
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1734 ret = g_string_append_c(ret, *e);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1735 e++;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1736 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1737 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1738
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1739 g_free(val);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1740 val = ret->str;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1741 g_string_free(ret, FALSE);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1742 return val;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
1743 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1744
8334
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1745 static const char *accepted_protocols[] = {
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1746 "http://",
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1747 "https://",
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1748 "ftp://"
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1749 };
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1750
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1751 static const int accepted_protocols_size = 3;
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1752
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1753 /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1754 the caller knows how long the protocol string is. */
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1755 int gtk_imhtml_is_protocol(const char *text)
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1756 {
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1757 gint i;
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1758
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1759 for(i=0; i<accepted_protocols_size; i++){
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1760 if( strncasecmp(text, accepted_protocols[i], strlen(accepted_protocols[i])) == 0 ){
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1761 return strlen(accepted_protocols[i]);
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1762 }
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1763 }
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1764 return 0;
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1765 }
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1766
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1767 /*
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1768 <KingAnt> marv: The two IM image functions in oscar are gaim_odc_send_im and gaim_odc_incoming
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1769
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1770
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1771 [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1772 [19:59] <KingAnt> marv: I think the image tag used by the core is something like <img id="#"/>
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1773 [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1774 [20:00] <KingAnt> marv: Where the ID is the what is returned when you add the image to the imgstore using gaim_imgstore_add
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1775 [20:00] <marv> Robot101: so how does the image get passed to serv_got_im() and serv_send_im()? just as the <img id="#" and then the prpl looks it up from the store?
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1776 [20:00] <KingAnt> marv: Right
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1777 [20:00] <marv> alright
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1778
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1779 Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1780 gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1781 function for gaim to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1782 images can be looked up like that, instead of passing a GSList of them.
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1783 */
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1784
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1785 void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1786 const gchar *text,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1787 GtkIMHtmlOptions options,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1788 GSList *unused)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1789 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1790 GtkTextIter iter, ins, sel;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1791 GdkRectangle rect;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1792 int y, height, ins_offset = 0, sel_offset = 0;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1793 gboolean fixins = FALSE, fixsel = FALSE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1794
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1795 g_return_if_fail (imhtml != NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1796 g_return_if_fail (GTK_IS_IMHTML (imhtml));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1797 g_return_if_fail (text != NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1798
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1799
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1800 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1801 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1802 if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1803 fixins = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1804 ins_offset = gtk_text_iter_get_offset(&ins);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1805 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1806
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1807 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1808 if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1809 fixsel = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1810 sel_offset = gtk_text_iter_get_offset(&sel);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1811 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1812
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1813 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1814 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1815
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1816
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1817 if(((y + height) - (rect.y + rect.height)) > height
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1818 && gtk_text_buffer_get_char_count(imhtml->text_buffer)){
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1819 options |= GTK_IMHTML_NO_SCROLL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1820 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1821
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1822 gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1823
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1824 if (fixins) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1825 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1826 gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1827 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1828
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1829 if (fixsel) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1830 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1831 gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1832 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1833
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1834 if (!(options & GTK_IMHTML_NO_SCROLL)) {
8729
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1835 gtk_imhtml_scroll_to_end(imhtml);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1836 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1837 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1838
8729
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1839 void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml)
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1840 {
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1841 GtkTextIter iter;
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1842 /* If this seems backwards at first glance, well it's not.
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1843 * It means scroll such that the mark is closest to the top,
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1844 * and closest to the right as possible. Remember kids, you have
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1845 * to scroll left to move a given spot closest to the right,
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1846 * and scroll down to move a spot closest to the top.
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1847 */
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1848 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1849 gtk_text_iter_set_line_offset(&iter, 0);
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1850 gtk_text_buffer_move_mark(imhtml->text_buffer, imhtml->scrollpoint, &iter);
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1851 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), imhtml->scrollpoint,
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1852 0, TRUE, 1.0, 0.0);
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1853 }
7024b9145357 [gaim-migrate @ 9484]
Luke Schierer <lschiere@pidgin.im>
parents: 8726
diff changeset
1854
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1855 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1856 const gchar *text,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1857 GtkIMHtmlOptions options,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1858 GtkTextIter *iter)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1859 {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1860 GdkRectangle rect;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1861 gint pos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1862 gchar *ws;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1863 gchar *tag;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1864 gchar *bg = NULL;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1865 gint len;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1866 gint tlen, smilelen, wpos=0;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1867 gint type;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1868 const gchar *c;
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1869 gchar *amp;
8334
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
1870 gint len_protocol;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1871
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1874 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1875 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1876 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1877 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1878 title = 0,
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1879 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1880
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1881 GSList *fonts = NULL;
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
1882 GObject *object;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1883 GtkIMHtmlScalable *scalable = NULL;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1884
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1885 g_return_if_fail (imhtml != NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1886 g_return_if_fail (GTK_IS_IMHTML (imhtml));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1887 g_return_if_fail (text != NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1888 c = text;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1889 len = strlen(text);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1890 ws = g_malloc(len + 1);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1891 ws[0] = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1893 while (pos < len) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1894 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1895 c++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1896 pos++;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1897 ws[wpos] = '\0';
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1898 switch (type)
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1899 {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1900 case 1: /* B */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1901 case 2: /* BOLD */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1902 case 54: /* STRONG */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1903
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1904 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1905
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1906 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD))
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1907 gtk_imhtml_toggle_bold(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1908 bold++;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1909 ws[0] = '\0'; wpos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1910 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1911 case 3: /* /B */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1912 case 4: /* /BOLD */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1913 case 55: /* /STRONG */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1914 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1915 ws[0] = '\0'; wpos = 0;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1916
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1917 if (bold)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1918 bold--;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1919 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1920 gtk_imhtml_toggle_bold(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1921 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1922 case 5: /* I */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1923 case 6: /* ITALIC */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1924 case 52: /* EM */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1925 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1926 ws[0] = '\0'; wpos = 0;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1927 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC))
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1928 gtk_imhtml_toggle_italic(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1929 italics++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1930 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1931 case 7: /* /I */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1932 case 8: /* /ITALIC */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1933 case 53: /* /EM */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1934 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1935 ws[0] = '\0'; wpos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1936 if (italics)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1937 italics--;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1938 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1939 gtk_imhtml_toggle_italic(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1940 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1941 case 9: /* U */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1942 case 10: /* UNDERLINE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1943 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1944 ws[0] = '\0'; wpos = 0;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1945 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE))
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1946 gtk_imhtml_toggle_underline(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1947 underline++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1948 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1949 case 11: /* /U */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1950 case 12: /* /UNDERLINE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1951 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1952 ws[0] = '\0'; wpos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1953 if (underline)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1954 underline--;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1955 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1956 gtk_imhtml_toggle_underline(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1957 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1958 case 13: /* S */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1959 case 14: /* STRIKE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1960 /* FIXME: reimplement this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1961 strike++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1962 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1963 case 15: /* /S */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1964 case 16: /* /STRIKE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1965 /* FIXME: reimplement this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1966 if (strike)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1967 strike--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1968 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1969 case 17: /* SUB */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1970 /* FIXME: reimpliment this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1971 sub++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1972 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1973 case 18: /* /SUB */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1974 /* FIXME: reimpliment this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1975 if (sub)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1976 sub--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1977 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1978 case 19: /* SUP */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1979 /* FIXME: reimplement this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1980 sup++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1981 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1982 case 20: /* /SUP */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1983 /* FIXME: reimplement this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1984 if (sup)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1985 sup--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1986 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1987 case 21: /* PRE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1988 /* FIXME: reimplement this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1989 pre++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1990 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1991 case 22: /* /PRE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1992 /* FIXME: reimplement this */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1993 if (pre)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1994 pre--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1995 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1996 case 23: /* TITLE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
1997 /* FIXME: what was this supposed to do anyway? */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1998 title++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1999 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2000 case 24: /* /TITLE */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2001 /* FIXME: make this undo whatever 23 was supposed to do */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2002 if (title) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2003 if (options & GTK_IMHTML_NO_TITLE) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2004 wpos = 0;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2005 ws [wpos] = '\0';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2006 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2007 title--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2008 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2009 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2010 case 25: /* BR */
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5118
diff changeset
2011 case 58: /* BR/ */
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2012 case 61: /* BR (opt) */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2013 ws[wpos] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2014 wpos++;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2015 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2016 case 26: /* HR */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2017 case 42: /* HR (opt) */
8726
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2018 {
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2019 int minus;
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2020
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2021 ws[wpos++] = '\n';
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2022 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2023
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2024 scalable = gtk_imhtml_hr_new();
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2025 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2026 scalable->add_to(scalable, imhtml, iter);
8726
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2027 minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) +
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2028 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml));
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2029 scalable->scale(scalable, rect.width - minus, rect.height);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2030 imhtml->scalables = g_list_append(imhtml->scalables, scalable);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2031 ws[0] = '\0'; wpos = 0;
7942
3e268e113bf1 [gaim-migrate @ 8613]
Mark Doliner <mark@kingant.net>
parents: 7914
diff changeset
2032 ws[wpos++] = '\n';
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2033
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2034 break;
8726
3ac178eedac2 [gaim-migrate @ 9481]
Ethan Blanton <elb@pidgin.im>
parents: 8719
diff changeset
2035 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2036 case 27: /* /FONT */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2037 if (fonts && !imhtml->wbfo) {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2038 GtkIMHtmlFontDetail *font = fonts->data;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2039 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2040 ws[0] = '\0'; wpos = 0;
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2041 /* NEW_BIT (NEW_TEXT_BIT); */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2042
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2043 if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2044 gtk_imhtml_toggle_fontface(imhtml, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2045 g_free (font->face);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2046 }
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2047 if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2048 gtk_imhtml_toggle_forecolor(imhtml, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2049 g_free (font->fore);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2050 }
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2051 if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2052 gtk_imhtml_toggle_backcolor(imhtml, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2053 g_free (font->back);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2054 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2055 if (font->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2056 g_free (font->sml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2057 g_free (font);
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2058
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2059 if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)))
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2060 gtk_imhtml_font_set_size(imhtml, 3);
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2061
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2062 fonts = fonts->next;
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2063 if (fonts) {
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2064 GtkIMHtmlFontDetail *font = fonts->data;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2065
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2066 if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE))
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2067 gtk_imhtml_toggle_fontface(imhtml, font->face);
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2068 if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR))
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2069 gtk_imhtml_toggle_forecolor(imhtml, font->fore);
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2070 if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR))
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2071 gtk_imhtml_toggle_backcolor(imhtml, font->back);
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2072 if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)))
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2073 gtk_imhtml_font_set_size(imhtml, font->size);
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2074 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2075 }
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2076 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2077 case 28: /* /A */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2078 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2079 gtk_imhtml_toggle_link(imhtml, NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2080 ws[0] = '\0'; wpos = 0;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2081 break;
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2082
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2083 case 29: /* P */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2084 case 30: /* /P */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2085 case 31: /* H3 */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2086 case 32: /* /H3 */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2087 case 33: /* HTML */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2088 case 34: /* /HTML */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2089 case 35: /* BODY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2090 case 36: /* /BODY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2091 case 37: /* FONT */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2092 case 38: /* HEAD */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2093 case 39: /* /HEAD */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2094 case 40: /* BINARY */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2095 case 41: /* /BINARY */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2096 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2097 case 43: /* FONT (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2098 {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2099 gchar *color, *back, *face, *size, *sml;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2100 GtkIMHtmlFontDetail *font, *oldfont = NULL;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2101 color = gtk_imhtml_get_html_opt (tag, "COLOR=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2102 back = gtk_imhtml_get_html_opt (tag, "BACK=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2103 face = gtk_imhtml_get_html_opt (tag, "FACE=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2104 size = gtk_imhtml_get_html_opt (tag, "SIZE=");
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2105 sml = gtk_imhtml_get_html_opt (tag, "SML=");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2106 if (!(color || back || face || size || sml))
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2107 break;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2108
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2109 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2110 ws[0] = '\0'; wpos = 0;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2111
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2112 font = g_new0 (GtkIMHtmlFontDetail, 1);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2113 if (fonts)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2114 oldfont = fonts->data;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2115
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2116 if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2117 font->fore = color;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2118 gtk_imhtml_toggle_forecolor(imhtml, font->fore);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2119 }
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2120 //else if (oldfont && oldfont->fore)
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2121 // font->fore = g_strdup(oldfont->fore);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2122
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2123 if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2124 font->back = back;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2125 gtk_imhtml_toggle_backcolor(imhtml, font->back);
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2126 }
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2127 //else if (oldfont && oldfont->back)
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2128 // font->back = g_strdup(oldfont->back);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2129
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2130 if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2131 font->face = face;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2132 gtk_imhtml_toggle_fontface(imhtml, font->face);
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2133 }
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2134 //else if (oldfont && oldfont->face)
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2135 // font->face = g_strdup(oldfont->face);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2136
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2137 if (sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2138 font->sml = sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2139 else if (oldfont && oldfont->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2140 font->sml = g_strdup(oldfont->sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2141
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2142 if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2143 if (*size == '+') {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2144 sscanf (size + 1, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2145 font->size += 3;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2146 } else if (*size == '-') {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2147 sscanf (size + 1, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2148 font->size = MAX (0, 3 - font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2149 } else if (isdigit (*size)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2150 sscanf (size, "%hd", &font->size);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2151 }
6042
460b4ba2d452 [gaim-migrate @ 6492]
Mark Doliner <mark@kingant.net>
parents: 5967
diff changeset
2152 if (font->size > 100)
460b4ba2d452 [gaim-migrate @ 6492]
Mark Doliner <mark@kingant.net>
parents: 5967
diff changeset
2153 font->size = 100;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2154 } else if (oldfont)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2155 font->size = oldfont->size;
8309
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2156 else
f694277e8341 [gaim-migrate @ 9033]
Sean Egan <seanegan@gmail.com>
parents: 8250
diff changeset
2157 font->size = 3;
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2158 if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)))
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2159 gtk_imhtml_font_set_size(imhtml, font->size);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2160 g_free(size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2161 fonts = g_slist_prepend (fonts, font);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2162 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2163 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2164 case 44: /* BODY (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2165 if (!(options & GTK_IMHTML_NO_COLOURS)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2166 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR=");
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2167 if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2168 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2169 ws[0] = '\0'; wpos = 0;
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2170 /* NEW_BIT(NEW_TEXT_BIT); */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2171 if (bg)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2172 g_free(bg);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2173 bg = bgcolor;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2174 gtk_imhtml_toggle_backcolor(imhtml, bg);
2885
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
2175 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2176 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2177 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2178 case 45: /* A (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2179 {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2180 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF=");
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2181 if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2182 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2183 ws[0] = '\0'; wpos = 0;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2184 gtk_imhtml_toggle_link(imhtml, href);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2185 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2186 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2187 break;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2188 case 46: /* IMG (opt) */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2189 case 59: /* IMG */
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2190 {
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2191 const char *id;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2192
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2193 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2194 ws[0] = '\0'; wpos = 0;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2195
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2196 if (!(imhtml->format_functions & GTK_IMHTML_IMAGE))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2197 break;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2198
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2199 id = gtk_imhtml_get_html_opt(tag, "ID=");
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2200
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2201 gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2202 break;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2203 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2204 case 47: /* P (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2205 case 48: /* H3 (opt) */
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
2206 case 49: /* HTML (opt) */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2207 case 50: /* CITE */
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2208 case 51: /* /CITE */
8026
17b90334f3cc [gaim-migrate @ 8706]
Nathan Walp <nwalp@pidgin.im>
parents: 7991
diff changeset
2209 case 56: /* SPAN (opt) */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2210 /* Inline CSS Support - Douglas Thrift
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2211 *
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2212 * color
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2213 * background
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2214 * font-family
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2215 * font-size
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2216 * text-decoration: underline
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2217 */
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2218 {
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2219 gchar *style, *color, *background, *family, *size;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2220 gchar *textdec;
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2221 GtkIMHtmlFontDetail *font, *oldfont = NULL;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2222 style = gtk_imhtml_get_html_opt (tag, "style=");
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2223
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2224 if (!style) break;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2225
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2226 color = gtk_imhtml_get_css_opt (style, "color: ");
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2227 background = gtk_imhtml_get_css_opt (style, "background: ");
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2228 family = gtk_imhtml_get_css_opt (style,
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2229 "font-family: ");
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2230 size = gtk_imhtml_get_css_opt (style, "font-size: ");
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2231 textdec = gtk_imhtml_get_css_opt (style, "text-decoration: ");
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2232
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2233 if (!(color || family || size || background || textdec)) {
8120
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8118
diff changeset
2234 g_free(style);
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8118
diff changeset
2235 break;
81a63a9bff88 [gaim-migrate @ 8824]
Nathan Walp <nwalp@pidgin.im>
parents: 8118
diff changeset
2236 }
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2237
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2238
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2239 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2240 ws[0] = '\0'; wpos = 0;
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2241 /* NEW_BIT (NEW_TEXT_BIT); */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2242
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2243 font = g_new0 (GtkIMHtmlFontDetail, 1);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2244 if (fonts)
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2245 oldfont = fonts->data;
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2246
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2247 if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR))
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2248 {
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2249 font->fore = color;
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2250 gtk_imhtml_toggle_forecolor(imhtml, font->fore);
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2251 }
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2252 else if (oldfont && oldfont->fore)
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2253 font->fore = g_strdup(oldfont->fore);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2254
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2255 if (background && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR))
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2256 {
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2257 font->back = background;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2258 gtk_imhtml_toggle_backcolor(imhtml, font->back);
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2259 }
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2260 else if (oldfont && oldfont->back)
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2261 font->back = g_strdup(oldfont->back);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2262
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2263 if (family && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE))
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2264 {
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2265 font->face = family;
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2266 gtk_imhtml_toggle_fontface(imhtml, font->face);
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2267 }
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2268 else if (oldfont && oldfont->face)
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2269 font->face = g_strdup(oldfont->face);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2270 if (font->face && (atoi(font->face) > 100)) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2271 /* WTF is this? */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2272 g_free(font->face);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2273 font->face = g_strdup("100");
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2274 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2275
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2276 if (oldfont && oldfont->sml)
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2277 font->sml = g_strdup(oldfont->sml);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2278
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2279 if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) {
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2280 if (g_ascii_strcasecmp(size, "xx-small") == 0)
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2281 font->size = 1;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2282 else if (g_ascii_strcasecmp(size, "smaller") == 0
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2283 || g_ascii_strcasecmp(size, "x-small") == 0)
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2284 font->size = 2;
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2285 else if (g_ascii_strcasecmp(size, "larger") == 0
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2286 || g_ascii_strcasecmp(size, "medium") == 0)
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2287 font->size = 4;
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2288 else if (g_ascii_strcasecmp(size, "large") == 0)
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2289 font->size = 5;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2290 else if (g_ascii_strcasecmp(size, "x-large") == 0)
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2291 font->size = 6;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2292 else if (g_ascii_strcasecmp(size, "xx-large") == 0)
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2293 font->size = 7;
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2294 else
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2295 font->size = 3;
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2296 gtk_imhtml_font_set_size(imhtml, font->size);
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2297 }
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2298 else if (oldfont)
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2299 {
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2300 font->size = oldfont->size;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2301 }
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2302
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2303 if (oldfont)
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2304 {
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2305 font->underline = oldfont->underline;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2306 }
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2307 if (textdec && font->underline != 1
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
2308 && g_ascii_strcasecmp(textdec, "underline") == 0
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2309 && (imhtml->format_functions & GTK_IMHTML_UNDERLINE))
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2310 {
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2311 gtk_imhtml_toggle_underline(imhtml);
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2312 font->underline = 1;
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2313 }
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2314
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2315 g_free(style);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2316 g_free(size);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2317 fonts = g_slist_prepend (fonts, font);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2318 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2319 break;
5104
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
2320 case 57: /* /SPAN */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2321 /* Inline CSS Support - Douglas Thrift */
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2322 if (fonts && !imhtml->wbfo) {
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2323 GtkIMHtmlFontDetail *oldfont = NULL;
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2324 GtkIMHtmlFontDetail *font = fonts->data;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2325 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2326 ws[0] = '\0'; wpos = 0;
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2327 /* NEW_BIT (NEW_TEXT_BIT); */
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2328 fonts = g_slist_remove (fonts, font);
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2329 if (fonts)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2330 oldfont = fonts->data;
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2331
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2332 if (!oldfont) {
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2333 gtk_imhtml_font_set_size(imhtml, 3);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2334 if (font->underline)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2335 gtk_imhtml_toggle_underline(imhtml);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2336 gtk_imhtml_toggle_fontface(imhtml, NULL);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2337 gtk_imhtml_toggle_forecolor(imhtml, NULL);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2338 gtk_imhtml_toggle_backcolor(imhtml, NULL);
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2339 }
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2340 else
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2341 {
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2342
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2343 if (font->size != oldfont->size)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2344 gtk_imhtml_font_set_size(imhtml, oldfont->size);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2345
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2346 if (font->underline != oldfont->underline)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2347 gtk_imhtml_toggle_underline(imhtml);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2348
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2349 if (!oldfont->face || strcmp(font->face, oldfont->face) != 0)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2350 gtk_imhtml_toggle_fontface(imhtml, oldfont->face);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2351
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2352 if (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2353 gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2354
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2355 if (!oldfont->back || strcmp(font->back, oldfont->back) != 0)
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2356 gtk_imhtml_toggle_backcolor(imhtml, oldfont->back);
8686
140b0d020c43 [gaim-migrate @ 9439]
Luke Schierer <lschiere@pidgin.im>
parents: 8681
diff changeset
2357 }
8692
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2358
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2359 g_free (font->face);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2360 g_free (font->fore);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2361 g_free (font->back);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2362 g_free (font->sml);
0680ca680e92 [gaim-migrate @ 9445]
Luke Schierer <lschiere@pidgin.im>
parents: 8686
diff changeset
2363
8118
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2364 g_free (font);
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2365 }
52089b055c12 [gaim-migrate @ 8822]
Luke Schierer <lschiere@pidgin.im>
parents: 8105
diff changeset
2366 break;
8026
17b90334f3cc [gaim-migrate @ 8706]
Nathan Walp <nwalp@pidgin.im>
parents: 7991
diff changeset
2367 case 60: /* SPAN */
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2368 break;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2369 case 62: /* comment */
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2370 /* NEW_BIT (NEW_TEXT_BIT); */
8317
6f549c1d0829 [gaim-migrate @ 9041]
Sean Egan <seanegan@gmail.com>
parents: 8309
diff changeset
2371 ws[wpos] = '\0';
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2372 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2373
6124
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
2374 if (imhtml->show_comments)
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
2375 wpos = g_snprintf (ws, len, "%s", tag);
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2376 /* NEW_BIT (NEW_COMMENT_BIT); */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2377 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2378 default:
6882
4f8258b2bb8d [gaim-migrate @ 7428]
Luke Schierer <lschiere@pidgin.im>
parents: 6839
diff changeset
2379 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2380 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2381 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2382 pos += tlen;
4138
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
2383 if(tag)
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
2384 g_free(tag); /* This was allocated back in VALID_TAG() */
9029
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2385 } else if (gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) {
8473
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2386 GtkIMHtmlFontDetail *fd;
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2387
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2388 gchar *sml = NULL;
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2389 if (fonts) {
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2390 fd = fonts->data;
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2391 sml = fd->sml;
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2392 }
9029
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2393 if (!sml)
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2394 sml = imhtml->protocol_name;
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2395
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2396 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
2397 wpos = g_snprintf (ws, smilelen + 1, "%s", c);
8473
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2398
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2399 gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter);
8473
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2400
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
2401 c += smilelen;
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
2402 pos += smilelen;
8473
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2403 wpos = 0;
12fe38c195a6 [gaim-migrate @ 9206]
Luke Schierer <lschiere@pidgin.im>
parents: 8466
diff changeset
2404 ws[0] = 0;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2405 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &amp, &tlen)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
2406 while(*amp) {
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
2407 ws [wpos++] = *amp++;
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
2408 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2409 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2410 pos += tlen;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2413 ws[wpos] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2414 wpos++;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2415 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2416 ws[0] = '\0';
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2417 wpos = 0;
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2418 /* NEW_BIT (NEW_TEXT_BIT); */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2421 pos++;
8334
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2422 } else if ((len_protocol = gtk_imhtml_is_protocol(c)) > 0){
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2423 while(len_protocol--){
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2424 /* Skip the next len_protocol characters, but make sure they're
8334
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2425 copied into the ws array.
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2426 */
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2427 ws [wpos++] = *c++;
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2428 pos++;
0d1e5870d328 [gaim-migrate @ 9058]
Luke Schierer <lschiere@pidgin.im>
parents: 8317
diff changeset
2429 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2430 } else if (*c) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 ws [wpos++] = *c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2432 pos++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2433 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2434 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2437 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2438 ws[0] = '\0'; wpos = 0;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2439
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
2440 /* NEW_BIT(NEW_TEXT_BIT); */
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2441
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2442 while (fonts) {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2443 GtkIMHtmlFontDetail *font = fonts->data;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2444 fonts = g_slist_remove (fonts, font);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2445 if (font->face)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2446 g_free (font->face);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2447 if (font->fore)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2448 g_free (font->fore);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2449 if (font->back)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2450 g_free (font->back);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2451 if (font->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2452 g_free (font->sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2453 g_free (font);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
2454 }
8932
849507541e86 [gaim-migrate @ 9702]
Tim Ringenbach <marv@pidgin.im>
parents: 8931
diff changeset
2455
849507541e86 [gaim-migrate @ 9702]
Tim Ringenbach <marv@pidgin.im>
parents: 8931
diff changeset
2456 g_free(ws);
849507541e86 [gaim-migrate @ 9702]
Tim Ringenbach <marv@pidgin.im>
parents: 8931
diff changeset
2457 if (bg)
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4629
diff changeset
2458 g_free(bg);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2459
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2460 if (!imhtml->wbfo)
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2461 gtk_imhtml_close_tags(imhtml, iter);
8506
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
2462
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
2463 object = g_object_ref(G_OBJECT(imhtml));
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
2464 g_signal_emit(object, signals[UPDATE_FORMAT], 0);
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
2465 g_object_unref(object);
887c0259b47b [gaim-migrate @ 9242]
Luke Schierer <lschiere@pidgin.im>
parents: 8505
diff changeset
2466
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2467 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2468
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
2469 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
2470 {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
2471 g_hash_table_destroy(imhtml->smiley_data);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
2472 gtk_smiley_tree_destroy(imhtml->default_smilies);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
2473 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal,
4902
0bbccc88bc67 [gaim-migrate @ 5236]
Nathan Walp <nwalp@pidgin.im>
parents: 4895
diff changeset
2474 g_free, (GDestroyNotify)gtk_smiley_tree_destroy);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
2475 imhtml->default_smilies = gtk_smiley_tree_new();
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
2476 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
2477
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2478 void gtk_imhtml_show_comments (GtkIMHtml *imhtml,
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
2479 gboolean show)
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
2480 {
6124
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
2481 imhtml->show_comments = show;
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
2482 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
2483
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2484 void gtk_imhtml_html_shortcuts (GtkIMHtml *imhtml,
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2485 gboolean allow)
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2486 {
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2487 imhtml->html_shortcuts = allow;
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2488 }
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2489
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2490 void gtk_imhtml_smiley_shortcuts (GtkIMHtml *imhtml,
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2491 gboolean allow)
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2492 {
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2493 imhtml->smiley_shortcuts = allow;
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2494 }
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2495
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2496 void
9029
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2497 gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, const gchar *protocol_name) {
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2498 if (imhtml->protocol_name)
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2499 g_free(imhtml->protocol_name);
697e169dac12 [gaim-migrate @ 9805]
Tim Ringenbach <marv@pidgin.im>
parents: 9028
diff changeset
2500 imhtml->protocol_name = protocol_name ? g_strdup(protocol_name) : NULL;
8456
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2501 }
5f8d4ab6d375 [gaim-migrate @ 9186]
Luke Schierer <lschiere@pidgin.im>
parents: 8439
diff changeset
2502
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
2503 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
2504 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
2505 {
7991
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2506 GList *del;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2507 GtkTextIter start, end;
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
2508 GObject *object = g_object_ref(G_OBJECT(imhtml));
7991
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2509
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2510 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2511 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
2512 gtk_text_buffer_delete(imhtml->text_buffer, &start, &end);
7991
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2513
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2514 for(del = imhtml->scalables; del; del = del->next) {
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2515 GtkIMHtmlScalable *scale = del->data;
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2516 scale->free(scale);
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2517 }
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2518 g_list_free(imhtml->scalables);
096562205906 [gaim-migrate @ 8668]
Nathan Walp <nwalp@pidgin.im>
parents: 7988
diff changeset
2519 imhtml->scalables = NULL;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2520
8719
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
2521 gtk_imhtml_close_tags(imhtml, &start);
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
2522
8427
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
2523 g_signal_emit(object, signals[CLEAR_FORMAT], 0);
2e18099ded93 [gaim-migrate @ 9157]
Sean Egan <seanegan@gmail.com>
parents: 8420
diff changeset
2524 g_object_unref(object);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
2525 }
2363
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
2526
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
2527 void gtk_imhtml_page_up (GtkIMHtml *imhtml)
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
2528 {
5282
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2529 GdkRectangle rect;
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2530 GtkTextIter iter;
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
2531
5282
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2532 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2533 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x,
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2534 rect.y - rect.height);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2535 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2536
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
2537 }
5282
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2538 void gtk_imhtml_page_down (GtkIMHtml *imhtml)
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2539 {
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2540 GdkRectangle rect;
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2541 GtkTextIter iter;
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2542
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2543 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2544 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x,
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2545 rect.y + rect.height);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2546 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
2547 }
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
2548
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2549 /* GtkIMHtmlScalable, gtk_imhtml_image, gtk_imhtml_hr */
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2550 GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id)
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
2551 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2552 GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage));
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2553 GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixbuf(img));
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2554
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2555 GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2556 GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2557 GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free;
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
2558
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
2559 im_image->pixbuf = img;
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2560 im_image->image = image;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2561 im_image->width = gdk_pixbuf_get_width(img);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2562 im_image->height = gdk_pixbuf_get_height(img);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2563 im_image->mark = NULL;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2564 im_image->filename = filename ? g_strdup(filename) : NULL;
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2565 im_image->id = id;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2566
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
2567 g_object_ref(img);
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2568 return GTK_IMHTML_SCALABLE(im_image);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2569 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2570
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2571 void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height)
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2572 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2573 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2574
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2575 if(image->width > width || image->height > height){
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2576 GdkPixbuf *new_image = NULL;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2577 float factor;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2578 int new_width = image->width, new_height = image->height;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2579
8588
7f7679853f7b [gaim-migrate @ 9339]
Mark Doliner <mark@kingant.net>
parents: 8568
diff changeset
2580 if(image->width > (width - 2)){
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2581 factor = (float)(width)/image->width;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2582 new_width = width;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2583 new_height = image->height * factor;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2584 }
8588
7f7679853f7b [gaim-migrate @ 9339]
Mark Doliner <mark@kingant.net>
parents: 8568
diff changeset
2585 if(new_height >= (height - 2)){
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2586 factor = (float)(height)/new_height;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2587 new_height = height;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2588 new_width = new_width * factor;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2589 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2590
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
2591 new_image = gdk_pixbuf_scale_simple(image->pixbuf, new_width, new_height, GDK_INTERP_BILINEAR);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2592 gtk_image_set_from_pixbuf(image->image, new_image);
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2593 g_object_unref(G_OBJECT(new_image));
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2594 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2595 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
2596
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2597 static void write_img_to_file(GtkWidget *w, GtkFileSelection *sel)
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2598 {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2599 const gchar *filename = gtk_file_selection_get_filename(sel);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2600 gchar *dirname;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2601 GtkIMHtmlImage *image = g_object_get_data(G_OBJECT(sel), "GtkIMHtmlImage");
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2602 gchar *type = NULL;
5019
eb1d45bffe66 [gaim-migrate @ 5355]
Luke Schierer <lschiere@pidgin.im>
parents: 5015
diff changeset
2603 GError *error = NULL;
5015
a17a84895585 [gaim-migrate @ 5351]
Nathan Walp <nwalp@pidgin.im>
parents: 5012
diff changeset
2604 #if GTK_CHECK_VERSION(2,2,0)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2605 GSList *formats = gdk_pixbuf_get_formats();
6162
7e967f2d6721 [gaim-migrate @ 6642]
Mark Doliner <mark@kingant.net>
parents: 6124
diff changeset
2606 #else
7e967f2d6721 [gaim-migrate @ 6642]
Mark Doliner <mark@kingant.net>
parents: 6124
diff changeset
2607 char *basename = g_path_get_basename(filename);
7e967f2d6721 [gaim-migrate @ 6642]
Mark Doliner <mark@kingant.net>
parents: 6124
diff changeset
2608 char *ext = strrchr(basename, '.');
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
2609 #endif
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2610
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2611 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2612 /* append a / if needed */
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2613 if (filename[strlen(filename) - 1] != '/') {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2614 dirname = g_strconcat(filename, "/", NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2615 } else {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2616 dirname = g_strdup(filename);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2617 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2618 gtk_file_selection_set_filename(sel, dirname);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2619 g_free(dirname);
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
2620 return;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2621 }
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
2622
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
2623 #if GTK_CHECK_VERSION(2,2,0)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2624 while(formats){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2625 GdkPixbufFormat *format = formats->data;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2626 gchar **extensions = gdk_pixbuf_format_get_extensions(format);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2627 gpointer p = extensions;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2628
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2629 while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2630 gchar *fmt_ext = extensions[0];
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2631 const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2632
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2633 if(!strcmp(fmt_ext, file_ext)){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2634 type = gdk_pixbuf_format_get_name(format);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2635 break;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2636 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2637
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2638 extensions++;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2639 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2640
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2641 g_strfreev(p);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2642
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2643 if(type)
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2644 break;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2645
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2646 formats = formats->next;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2647 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2648
5020
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2649 g_slist_free(formats);
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2650 #else
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2651 /* this is really ugly code, but I think it will work */
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2652 if(ext) {
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2653 ext++;
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2654 if(!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg"))
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2655 type = g_strdup("jpeg");
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2656 else if(!g_ascii_strcasecmp(ext, "png"))
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2657 type = g_strdup("png");
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2658 }
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2659
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2660 g_free(basename);
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2661 #endif
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
2662
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2663 /* If I can't find a valid type, I will just tell the user about it and then assume
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2664 it's a png */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2665 if(!type){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2666 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2667 _("Unable to guess the image type based on the file extension supplied. Defaulting to PNG."));
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2668 type = g_strdup("png");
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2669 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2670
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
2671 gdk_pixbuf_save(image->pixbuf, filename, type, &error, NULL);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2672
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2673 if(error){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2674 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2675 _("Error saving image: %s"), error->message);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2676 g_error_free(error);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2677 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2678
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2679 g_free(type);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2680 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2681
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2682 static void gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImage *image)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2683 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2684 GtkWidget *sel = gtk_file_selection_new(_("Save Image"));
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2685
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2686 if (image->filename)
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2687 gtk_file_selection_set_filename(GTK_FILE_SELECTION(sel), image->filename);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2688 g_object_set_data(G_OBJECT(sel), "GtkIMHtmlImage", image);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2689 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(sel)->ok_button), "clicked",
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2690 G_CALLBACK(write_img_to_file), sel);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2691
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2692 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(sel)->ok_button), "clicked",
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2693 G_CALLBACK(gtk_widget_destroy), sel);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2694 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(sel)->cancel_button), "clicked",
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2695 G_CALLBACK(gtk_widget_destroy), sel);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2696
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2697 gtk_widget_show(sel);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2698 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2699
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2700 static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImage *image)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2701 {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2702 GdkEventButton *event_button = (GdkEventButton *) event;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2703
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2704 if (event->type == GDK_BUTTON_RELEASE) {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2705 if(event_button->button == 3) {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2706 GtkWidget *img, *item, *menu;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2707 gchar *text = g_strdup_printf(_("_Save Image..."));
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2708 menu = gtk_menu_new();
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2709
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2710 /* buttons and such */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2711 img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2712 item = gtk_image_menu_item_new_with_mnemonic(text);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2713 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2714 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), image);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2715 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2716
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2717 gtk_widget_show_all(menu);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2718 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2719 event_button->button, event_button->time);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2720
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2721 g_free(text);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2722 return TRUE;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2723 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2724 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2725 if(event->type == GDK_BUTTON_PRESS && event_button->button == 3)
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2726 return TRUE; /* Clicking the right mouse button on a link shouldn't
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2727 be caught by the regular GtkTextView menu */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2728 else
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2729 return FALSE; /* Let clicks go through if we didn't catch anything */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2730
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
2731 }
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2732 void gtk_imhtml_image_free(GtkIMHtmlScalable *scale)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2733 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2734 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2735
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2736 g_object_unref(image->pixbuf);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2737 if (image->filename)
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
2738 g_free(image->filename);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2739 g_free(scale);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2740 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2741
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2742 void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2743 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2744 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2745 GtkWidget *box = gtk_event_box_new();
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2746 char *tag;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2747 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2748
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2749 gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image));
9078
f06013ff80d9 [gaim-migrate @ 9854]
Tim Ringenbach <marv@pidgin.im>
parents: 9071
diff changeset
2750 #if GTK_CHECK_VERSION(2,4,0)
f06013ff80d9 [gaim-migrate @ 9854]
Tim Ringenbach <marv@pidgin.im>
parents: 9071
diff changeset
2751 gtk_event_box_set_visible_window(GTK_EVENT_BOX(box), FALSE);
f06013ff80d9 [gaim-migrate @ 9854]
Tim Ringenbach <marv@pidgin.im>
parents: 9071
diff changeset
2752 #endif
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2753
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2754 gtk_widget_show(GTK_WIDGET(image->image));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2755 gtk_widget_show(box);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2756
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2757 tag = g_strdup_printf("<IMG ID=\"%d\">", image->id);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2758 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2759 g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]");
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
2760
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2761 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), box, anchor);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2762 g_signal_connect(G_OBJECT(box), "event", G_CALLBACK(gtk_imhtml_image_clicked), image);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2763 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2764
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2765 GtkIMHtmlScalable *gtk_imhtml_hr_new()
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2766 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2767 GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2768
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2769 GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2770 GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2771 GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2772
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2773 hr->sep = gtk_hseparator_new();
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2774 gtk_widget_set_size_request(hr->sep, 5000, 2);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2775 gtk_widget_show(hr->sep);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2776
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2777 return GTK_IMHTML_SCALABLE(hr);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2778 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2779
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2780 void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2781 {
8588
7f7679853f7b [gaim-migrate @ 9339]
Mark Doliner <mark@kingant.net>
parents: 8568
diff changeset
2782 gtk_widget_set_size_request(((GtkIMHtmlHr *)scale)->sep, width - 2, 2);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2783 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2784
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2785 void gtk_imhtml_hr_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2786 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2787 GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2788 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter);
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2789 g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>");
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
2790 g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n");
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2791 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), hr->sep, anchor);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2792 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2793
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2794 void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2795 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2796 g_free(scale);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2797 }
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2798
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2799 gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text)
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2800 {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2801 GtkTextIter iter, start, end;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2802 gboolean new_search = TRUE;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2803
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2804 g_return_val_if_fail(imhtml != NULL, FALSE);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2805 g_return_val_if_fail(text != NULL, FALSE);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2806
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2807 if (imhtml->search_string && !strcmp(text, imhtml->search_string))
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2808 new_search = FALSE;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2809
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2810 if (new_search) {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2811 gtk_imhtml_search_clear(imhtml);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2812 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2813 } else {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2814 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter,
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2815 gtk_text_buffer_get_mark(imhtml->text_buffer, "search"));
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2816 }
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2817 imhtml->search_string = g_strdup(text);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2818
7358
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
2819 if (gtk_source_iter_forward_search(&iter, imhtml->search_string,
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
2820 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2821 &start, &end, NULL)) {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2822
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2823 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2824 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &end, FALSE);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2825 if (new_search) {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2826 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2827 do
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2828 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2829 while (gtk_source_iter_forward_search(&end, imhtml->search_string,
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2830 GTK_SOURCE_SEARCH_VISIBLE_ONLY |
7358
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
2831 GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2832 &start, &end, NULL));
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2833 }
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2834 return TRUE;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2835 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2836
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2837 gtk_imhtml_search_clear(imhtml);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2838
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2839 return FALSE;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2840 }
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2841
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2842 void gtk_imhtml_search_clear(GtkIMHtml *imhtml)
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2843 {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2844 GtkTextIter start, end;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2845
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2846 g_return_if_fail(imhtml != NULL);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2847
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2848 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2849 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2850
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2851 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &start, &end);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2852 if (imhtml->search_string)
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2853 g_free(imhtml->search_string);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2854 imhtml->search_string = NULL;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2855 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2856
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2857 static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2858 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2859 gchar str[18];
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2860 GtkTextTag *tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2861
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2862 g_snprintf(str, sizeof(str), "FORECOLOR %s", color);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2863
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2864 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2865 if (!tag)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2866 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", color, NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2867
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2868 return tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2869 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2870
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2871 static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2872 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2873 gchar str[18];
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2874 GtkTextTag *tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2875
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2876 g_snprintf(str, sizeof(str), "BACKCOLOR %s", color);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2877
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2878 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2879 if (!tag)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2880 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background", color, NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2881
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2882 return tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2883 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2884
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2885 static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2886 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2887 gchar str[256];
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2888 GtkTextTag *tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2889
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2890 g_snprintf(str, sizeof(str), "FONT FACE %s", face);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2891 str[255] = '\0';
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2892
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2893 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2894 if (!tag)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2895 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2896
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2897 return tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2898 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2899
8740
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2900 static void _init_original_fsize(GtkIMHtml *imhtml)
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2901 {
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2902 GtkTextAttributes *attr;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2903 attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml));
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2904 imhtml->original_fsize = pango_font_description_get_size(attr->font);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2905 gtk_text_attributes_unref(attr);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2906 }
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2907
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2908 static void _recalculate_font_sizes(GtkTextTag *tag, gpointer imhtml)
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2909 {
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2910 if (strncmp(tag->name, "FONT SIZE ", 10) == 0) {
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2911 int size;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2912
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2913 size = strtol(tag->name + 10, NULL, 10);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2914 g_object_set(G_OBJECT(tag), "size",
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2915 (gint) (GTK_IMHTML(imhtml)->original_fsize *
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2916 ((double) _point_sizes[size-1] * GTK_IMHTML(imhtml)->zoom)), NULL);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2917 }
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2918
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2919
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2920 }
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2921
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2922 void gtk_imhtml_font_zoom(GtkIMHtml *imhtml, double zoom)
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2923 {
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2924 GtkRcStyle *s;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2925 PangoFontDescription *font_desc = pango_font_description_new();
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2926
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2927 imhtml->zoom = zoom;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2928
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2929 if (!imhtml->original_fsize)
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2930 _init_original_fsize(imhtml);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2931
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2932 gtk_text_tag_table_foreach(gtk_text_buffer_get_tag_table(imhtml->text_buffer),
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2933 _recalculate_font_sizes, imhtml);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2934
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2935 pango_font_description_set_size(font_desc, (gint)((double) imhtml->original_fsize * zoom));
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2936
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2937 s = gtk_widget_get_modifier_style(GTK_WIDGET(imhtml));
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2938 s->font_desc = font_desc;
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2939 gtk_widget_modify_style(GTK_WIDGET(imhtml), s);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2940 }
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2941
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2942 static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2943 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2944 gchar str[24];
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2945 GtkTextTag *tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2946
8740
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2947 if (!imhtml->original_fsize)
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2948 _init_original_fsize(imhtml);
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2949
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2950 g_snprintf(str, sizeof(str), "FONT SIZE %d", size);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2951 str[23] = '\0';
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2952
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2953 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2954 if (!tag) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2955 /* For reasons I don't understand, setting "scale" here scaled based on some default
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2956 * size other than my theme's default size. Our size 4 was actually smaller than
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2957 * our size 3 for me. So this works around that oddity.
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2958 */
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2959 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size",
8740
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2960 (gint) (imhtml->original_fsize *
61a090413b93 [gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
2961 ((double) _point_sizes[size-1] * imhtml->zoom)), NULL);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2962 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2963
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2964 return tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2965 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2966
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2967 static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2968 const char *prefix, guint len, gboolean homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2969 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2970 GSList *tags, *l;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2971 GtkTextIter iter;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2972
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2973 tags = gtk_text_iter_get_tags(i);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2974
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2975 for (l = tags; l; l = l->next) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2976 GtkTextTag *tag = l->data;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2977
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2978 if (tag->name && !strncmp(tag->name, prefix, len))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2979 gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2980 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
2981
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2982 g_slist_free(tags);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2983
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2984 if (homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2985 return;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2986
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2987 iter = *i;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2988
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2989 while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2990 if (gtk_text_iter_begins_tag(&iter, NULL)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2991 tags = gtk_text_iter_get_toggled_tags(&iter, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2992
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2993 for (l = tags; l; l = l->next) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2994 GtkTextTag *tag = l->data;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2995
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2996 if (tag->name && !strncmp(tag->name, prefix, len))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2997 gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2998 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
2999
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3000 g_slist_free(tags);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3001 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3002 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3003 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3004
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3005 static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3006 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3007 remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3008 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3009
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3010 static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3011 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3012 remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3013 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3014
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3015 static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3016 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3017 remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3018 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3019
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3020 static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3021 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3022 remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3023 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3024
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3025 static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3026 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3027 remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3028 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3029
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3030 /* Editable stuff */
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3031 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3032 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3033 imhtml->insert_offset = gtk_text_iter_get_offset(iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3034 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3035
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3036 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3037 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3038 GtkTextIter start;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3039
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3040 if (!len)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3041 return;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3042
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3043 start = *end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3044 gtk_text_iter_set_offset(&start, imhtml->insert_offset);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3045
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3046 if (imhtml->edit.bold)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3047 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3048 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3049 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3050
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3051 if (imhtml->edit.italic)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3052 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3053 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3054 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3055
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3056 if (imhtml->edit.underline)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3057 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3058 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3059 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3060
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3061 if (imhtml->edit.forecolor) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3062 remove_font_forecolor(imhtml, &start, end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3063 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3064 find_font_forecolor_tag(imhtml, imhtml->edit.forecolor),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3065 &start, end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3066 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3067
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3068 if (imhtml->edit.backcolor) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3069 remove_font_backcolor(imhtml, &start, end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3070 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3071 find_font_backcolor_tag(imhtml, imhtml->edit.backcolor),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3072 &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3073 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3074
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3075 if (imhtml->edit.fontface) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3076 remove_font_face(imhtml, &start, end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3077 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3078 find_font_face_tag(imhtml, imhtml->edit.fontface),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3079 &start, end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3080 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3081
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3082 if (imhtml->edit.fontsize) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3083 remove_font_size(imhtml, &start, end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3084 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3085 find_font_size_tag(imhtml, imhtml->edit.fontsize),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3086 &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3087 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3088
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3089 if (imhtml->edit.link) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3090 remove_font_link(imhtml, &start, end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3091 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3092 imhtml->edit.link,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3093 &start, end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3094 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3095
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3096 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3097
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3098 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3099 {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3100 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable);
8177
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
3101 /*
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
3102 * We need a visible caret for accessibility, so mouseless
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
3103 * people can highlight stuff.
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
3104 */
4e68644a47f6 [gaim-migrate @ 8891]
Mark Doliner <mark@kingant.net>
parents: 8149
diff changeset
3105 /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3106 imhtml->editable = editable;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3107 imhtml->format_functions = GTK_IMHTML_ALL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3108
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3109 if (editable)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3110 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set",
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3111 G_CALLBACK(mark_set_cb), imhtml);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3112 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3113
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3114 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3115 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3116 g_return_if_fail(imhtml != NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3117
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3118 imhtml->wbfo = wbfo;
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3119 }
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3120
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3121 void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons)
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3122 {
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3123 GObject *object = g_object_ref(G_OBJECT(imhtml));
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3124 imhtml->format_functions = buttons;
8420
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3125 g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons);
c25c697525b7 [gaim-migrate @ 9150]
Sean Egan <seanegan@gmail.com>
parents: 8380
diff changeset
3126 g_object_unref(object);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3127 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3128
8788
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8786
diff changeset
3129 GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml)
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8786
diff changeset
3130 {
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8786
diff changeset
3131 return imhtml->format_functions;
262f81346c0a [gaim-migrate @ 9550]
Mark Doliner <mark@kingant.net>
parents: 8786
diff changeset
3132 }
8516
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8515
diff changeset
3133
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8515
diff changeset
3134 void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold,
5b25f72c4723 [gaim-migrate @ 9254]
Luke Schierer <lschiere@pidgin.im>
parents: 8515
diff changeset
3135 gboolean *italic, gboolean *underline)
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3136 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3137 if (imhtml->edit.bold)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3138 (*bold) = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3139 if (imhtml->edit.italic)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3140 (*italic) = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3141 if (imhtml->edit.underline)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3142 (*underline) = TRUE;
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3143 }
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3144
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3145 char *
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3146 gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3147 {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3148 if (imhtml->edit.fontface)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3149 return g_strdup(imhtml->edit.fontface);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3150 else
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3151 return NULL;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3152 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3153
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3154 char *
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3155 gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3156 {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3157 if (imhtml->edit.forecolor)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3158 return g_strdup(imhtml->edit.forecolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3159 else
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3160 return NULL;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3161 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3162
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3163 char *
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3164 gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3165 {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3166 if (imhtml->edit.backcolor)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3167 return g_strdup(imhtml->edit.backcolor);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3168 else
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3169 return NULL;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3170 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3171
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3172 gint
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3173 gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3174 {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3175 return imhtml->edit.fontsize;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3176 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3177
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3178 gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3179 {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3180 return imhtml->editable;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3181 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3182
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3183 /*
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3184 * I had this crazy idea about changing the text cursor color to reflex the foreground color
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3185 * of the text about to be entered. This is the place you'd do it, along with the place where
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3186 * we actually set a new foreground color.
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3187 * I may not do this, because people will bitch about Gaim overriding their gtk theme's cursor
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3188 * colors.
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3189 *
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3190 * Just in case I do do this, I asked about what to set the secondary text cursor to.
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3191 *
8719
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
3192 * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
3193 * (12:45:55) ?? ???: understand?
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3194 * (12:46:14) Tim: yeah. i didn't know there was an exact formula
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8729
diff changeset
3195 * (12:46:56) ?? ???: u might need to extract separate each color from RGB
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3196 */
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3197
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3198 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3199 GtkIMHtml *imhtml)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3200 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3201 GSList *tags, *l;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3202 GtkTextIter iter;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3203
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3204 if (mark != gtk_text_buffer_get_insert(buffer))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3205 return;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3206
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3207 if (!gtk_text_buffer_get_char_count(buffer))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3208 return;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3209
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3210 imhtml->edit.bold = imhtml->edit.italic = imhtml->edit.underline = FALSE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3211 if (imhtml->edit.forecolor)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3212 g_free(imhtml->edit.forecolor);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3213 imhtml->edit.forecolor = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3214 if (imhtml->edit.backcolor)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3215 g_free(imhtml->edit.backcolor);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3216 imhtml->edit.backcolor = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3217 if (imhtml->edit.fontface)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3218 g_free(imhtml->edit.fontface);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3219 imhtml->edit.fontface = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3220 imhtml->edit.fontsize = 0;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3221 imhtml->edit.link = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3222
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3223 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3224
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3225
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3226 if (gtk_text_iter_is_end(&iter))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3227 tags = gtk_text_iter_get_toggled_tags(&iter, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3228 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3229 tags = gtk_text_iter_get_tags(&iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3230
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3231 for (l = tags; l != NULL; l = l->next) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3232 GtkTextTag *tag = GTK_TEXT_TAG(l->data);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3233
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3234 if (tag->name) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3235 if (strcmp(tag->name, "BOLD") == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3236 imhtml->edit.bold = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3237 if (strcmp(tag->name, "ITALICS") == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3238 imhtml->edit.italic = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3239 if (strcmp(tag->name, "UNDERLINE") == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3240 imhtml->edit.underline = TRUE;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3241 if (strncmp(tag->name, "FORECOLOR ", 10) == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3242 imhtml->edit.forecolor = g_strdup(&(tag->name)[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3243 if (strncmp(tag->name, "BACKCOLOR ", 10) == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3244 imhtml->edit.backcolor = g_strdup(&(tag->name)[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3245 if (strncmp(tag->name, "FONT FACE ", 10) == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3246 imhtml->edit.fontface = g_strdup(&(tag->name)[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3247 if (strncmp(tag->name, "FONT SIZE ", 10) == 0)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3248 imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10);
8719
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
3249 if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter))
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3250 imhtml->edit.link = tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3251 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3252 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3253
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3254 g_slist_free(tags);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3255 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3256
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3257 gboolean gtk_imhtml_toggle_bold(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3258 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3259 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3260 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3261
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3262 imhtml->edit.bold = !imhtml->edit.bold;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3263
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3264 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3265 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3266 if (imhtml->edit.bold)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3267 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3268 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3269 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3270 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3271 if (imhtml->edit.bold)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3272 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3273 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3274 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3275
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3276 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3277 object = g_object_ref(G_OBJECT(imhtml));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3278 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_BOLD);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3279 g_object_unref(object);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3280
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3281 return (imhtml->edit.bold != FALSE);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3282 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3283
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3284 gboolean gtk_imhtml_toggle_italic(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3285 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3286 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3287 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3288
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3289 imhtml->edit.italic = !imhtml->edit.italic;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3290
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3291 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3292 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3293 if (imhtml->edit.italic)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3294 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3295 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3296 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3297 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3298 if (imhtml->edit.italic)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3299 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3300 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3301 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3302 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3303 object = g_object_ref(G_OBJECT(imhtml));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3304 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_ITALIC);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3305 g_object_unref(object);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3306
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3307 return imhtml->edit.italic != FALSE;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3308 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3309
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3310 gboolean gtk_imhtml_toggle_underline(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3311 {
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3312 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3313 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3314
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3315 imhtml->edit.underline = !imhtml->edit.underline;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3316
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3317 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3318 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3319 if (imhtml->edit.underline)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3320 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3321 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3322 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3323 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3324 if (imhtml->edit.underline)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3325 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3326 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3327 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3328 }
8481
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3329 object = g_object_ref(G_OBJECT(imhtml));
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3330 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_UNDERLINE);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3331 g_object_unref(object);
6d0869404696 [gaim-migrate @ 9214]
Luke Schierer <lschiere@pidgin.im>
parents: 8473
diff changeset
3332
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3333 return imhtml->edit.underline != FALSE;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3334 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3335
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3336 void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3337 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3338 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3339 GtkTextIter start, end;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3340 GtkIMHtmlButtons b = 0;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3341
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3342 imhtml->edit.fontsize = size;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3343
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3344
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3345 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3346 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3347 remove_font_size(imhtml, &start, &end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3348 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3349 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3350 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3351 remove_font_size(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3352 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3353 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3354 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3355
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3356 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3357 b |= GTK_IMHTML_SHRINK;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3358 b |= GTK_IMHTML_GROW;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3359 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, b);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3360 g_object_unref(object);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3361 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3362
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3363 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3364 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3365 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3366 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3367
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3368 if (imhtml->edit.fontsize == 1)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3369 return;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3370
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3371 if (!imhtml->edit.fontsize)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3372 imhtml->edit.fontsize = 2;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3373 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3374 imhtml->edit.fontsize--;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3375
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3376 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3377 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3378 remove_font_size(imhtml, &start, &end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3379 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3380 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3381 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3382 remove_font_size(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3383 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3384 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3385 }
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3386 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3387 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3388 g_object_unref(object);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3389 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3390
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3391 void gtk_imhtml_font_grow(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3392 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3393 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3394 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3395
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3396 if (imhtml->edit.fontsize == MAX_FONT_SIZE)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3397 return;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3398
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3399 if (!imhtml->edit.fontsize)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3400 imhtml->edit.fontsize = 4;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3401 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3402 imhtml->edit.fontsize++;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3403
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3404 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3405 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3406 remove_font_size(imhtml, &start, &end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3407 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3408 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3409 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3410 remove_font_size(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3411 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3412 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3413 }
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3414 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3415 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_GROW);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3416 g_object_unref(object);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3417 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3418
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3419 gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3420 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3421 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3422 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3423
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3424 if (imhtml->edit.forecolor != NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3425 g_free(imhtml->edit.forecolor);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3426
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3427 if (color && strcmp(color, "") != 0) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3428 imhtml->edit.forecolor = g_strdup(color);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3429 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3430 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3431 remove_font_forecolor(imhtml, &start, &end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3432 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3433 find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3434 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3435 remove_font_forecolor(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3436 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3437 find_font_forecolor_tag(imhtml, imhtml->edit.forecolor),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3438 &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3439 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3440 } else {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3441 imhtml->edit.forecolor = NULL;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3442 if (imhtml->wbfo) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3443 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3444 remove_font_forecolor(imhtml, &start, &end, TRUE);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3445 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3446 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3447
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3448 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3449 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_FORECOLOR);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3450 g_object_unref(object);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3451
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3452 return imhtml->edit.forecolor != NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3453 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3454
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3455 gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3456 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3457 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3458 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3459
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3460 if (imhtml->edit.backcolor != NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3461 g_free(imhtml->edit.backcolor);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3462
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3463 if (color && strcmp(color, "") != 0) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3464 imhtml->edit.backcolor = g_strdup(color);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3465
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3466 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3467 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3468 remove_font_backcolor(imhtml, &start, &end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3469 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3470 find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3471 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3472 remove_font_backcolor(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3473 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3474 find_font_backcolor_tag(imhtml,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3475 imhtml->edit.backcolor), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3476 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3477 } else {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3478 imhtml->edit.backcolor = NULL;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3479 if (imhtml->wbfo) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3480 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3481 remove_font_backcolor(imhtml, &start, &end, TRUE);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3482 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3483 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3484
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3485 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3486 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_BACKCOLOR);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3487 g_object_unref(object);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3488
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3489 return imhtml->edit.backcolor != NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3490 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3491
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3492 gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3493 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3494 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3495 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3496
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3497 if (imhtml->edit.fontface != NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3498 g_free(imhtml->edit.fontface);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3499
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3500 if (face && strcmp(face, "") != 0) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3501 imhtml->edit.fontface = g_strdup(face);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3502
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3503 if (imhtml->wbfo) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3504 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3505 remove_font_face(imhtml, &start, &end, TRUE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3506 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3507 find_font_face_tag(imhtml, imhtml->edit.fontface), &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3508 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3509 remove_font_face(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3510 gtk_text_buffer_apply_tag(imhtml->text_buffer,
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3511 find_font_face_tag(imhtml, imhtml->edit.fontface),
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3512 &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3513 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3514 } else {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3515 imhtml->edit.fontface = NULL;
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3516 if (imhtml->wbfo) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3517 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3518 remove_font_face(imhtml, &start, &end, TRUE);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3519 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3520 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3521
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3522 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3523 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_FACE);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3524 g_object_unref(object);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3525
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3526 return imhtml->edit.fontface != NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3527 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3528
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3529 void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3530 {
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3531 GObject *object;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3532 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3533 GtkTextTag *linktag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3534 static guint linkno = 0;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3535 gchar str[48];
9007
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
3536 GdkColor *color = NULL;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3537
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3538 imhtml->edit.link = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3539
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3540
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3541
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3542 if (url) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3543 g_snprintf(str, sizeof(str), "LINK %d", linkno++);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3544 str[47] = '\0';
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3545
9007
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
3546 gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL);
9008
6dc1f052edc0 [gaim-migrate @ 9784]
Tim Ringenbach <marv@pidgin.im>
parents: 9007
diff changeset
3547 if (color) {
9007
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
3548 imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL);
9008
6dc1f052edc0 [gaim-migrate @ 9784]
Tim Ringenbach <marv@pidgin.im>
parents: 9007
diff changeset
3549 gdk_color_free(color);
6dc1f052edc0 [gaim-migrate @ 9784]
Tim Ringenbach <marv@pidgin.im>
parents: 9007
diff changeset
3550 } else {
9007
0a08f671b591 [gaim-migrate @ 9783]
Tim Ringenbach <marv@pidgin.im>
parents: 8962
diff changeset
3551 imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL);
9008
6dc1f052edc0 [gaim-migrate @ 9784]
Tim Ringenbach <marv@pidgin.im>
parents: 9007
diff changeset
3552 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3553 g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3554 g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3555
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3556 if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3557 remove_font_link(imhtml, &start, &end, FALSE);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3558 gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3559 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3560 }
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3561
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3562 object = g_object_ref(G_OBJECT(imhtml));
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3563 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 9008
diff changeset
3564 g_object_unref(object);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3565 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3566
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3567 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3568 {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3569 GtkTextIter iter;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3570
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3571 gtk_imhtml_toggle_link(imhtml, url);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3572 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3573 gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3574 gtk_imhtml_toggle_link(imhtml, NULL);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3575 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3576
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3577 void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3578 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3579 GtkTextMark *mark;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3580 GtkTextIter iter;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3581
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3582 mark = gtk_text_buffer_get_insert(imhtml->text_buffer);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3583
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3584 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3585 gtk_imhtml_insert_smiley_at_iter(imhtml, sml, smiley, &iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3586 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3587
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3588 void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3589 {
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3590 GdkPixbuf *pixbuf = NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3591 GdkPixbufAnimation *annipixbuf = NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3592 GtkWidget *icon = NULL;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3593 GtkTextChildAnchor *anchor;
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
3594 char *unescaped = gaim_unescape_html(smiley);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3595
8505
112f5762a41a [gaim-migrate @ 9241]
Luke Schierer <lschiere@pidgin.im>
parents: 8498
diff changeset
3596 annipixbuf = gtk_smiley_tree_image(imhtml, sml, unescaped);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3597 if(annipixbuf) {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3598 if(gdk_pixbuf_animation_is_static_image(annipixbuf)) {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3599 pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3600 if(pixbuf)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3601 icon = gtk_image_new_from_pixbuf(pixbuf);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3602 } else {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3603 icon = gtk_image_new_from_animation(annipixbuf);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3604 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3605 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3606
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3607 if (icon) {
8890
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3608 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter);
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3609 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free);
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3610 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free);
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3611
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3612 gtk_widget_show(icon);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3613 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), icon, anchor);
8890
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3614 } else {
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3615 gtk_text_buffer_insert(imhtml->text_buffer, iter, smiley, -1);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3616 }
8890
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3617
6c98b883580a [gaim-migrate @ 9659]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
3618 g_free(unescaped);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3619 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3620
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3621 void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter)
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3622 {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3623 GdkPixbuf *pixbuf = NULL;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3624 const char *filename = NULL;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3625 gpointer image;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3626 GdkRectangle rect;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3627 GtkIMHtmlScalable *scalable = NULL;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3628 int minus;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3629
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3630 if (!imhtml->funcs || !imhtml->funcs->image_get ||
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3631 !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data ||
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3632 !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref ||
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3633 !imhtml->funcs->image_unref)
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3634 return;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3635
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3636 image = imhtml->funcs->image_get(id);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3637
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3638 if (image) {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3639 gpointer data;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3640 size_t len;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3641
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3642 data = imhtml->funcs->image_get_data(image);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3643 len = imhtml->funcs->image_get_size(image);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3644
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3645 if (data && len) {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3646 GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3647 gdk_pixbuf_loader_write(loader, data, len, NULL);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3648 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3649 if (pixbuf)
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3650 g_object_ref(G_OBJECT(pixbuf));
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3651 gdk_pixbuf_loader_close(loader, NULL);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3652 }
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3653
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3654 }
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3655
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3656 if (pixbuf) {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3657 filename = imhtml->funcs->image_get_filename(image);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3658 imhtml->funcs->image_ref(id);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3659 imhtml->im_images = g_slist_prepend(imhtml->im_images, GINT_TO_POINTER(id));
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3660 } else {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3661 pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3662 GTK_ICON_SIZE_BUTTON, "gtkimhtml-missing-image");
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3663 }
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3664
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3665 scalable = gtk_imhtml_image_new(pixbuf, filename, id);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3666 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3667 scalable->add_to(scalable, imhtml, iter);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3668 minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) +
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3669 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml));
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3670 scalable->scale(scalable, rect.width - minus, rect.height);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3671 imhtml->scalables = g_list_append(imhtml->scalables, scalable);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3672
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3673 g_object_unref(G_OBJECT(pixbuf));
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3674 }
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3675
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3676 static const gchar *tag_to_html_start(GtkTextTag *tag)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3677 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3678 const gchar *name;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3679 static gchar buf[1024];
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3680
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3681 name = tag->name;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3682 g_return_val_if_fail(name != NULL, "");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3683
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3684 if (strcmp(name, "BOLD") == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3685 return "<b>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3686 } else if (strcmp(name, "ITALICS") == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3687 return "<i>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3688 } else if (strcmp(name, "UNDERLINE") == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3689 return "<u>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3690 } else if (strncmp(name, "LINK ", 5) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3691 char *tmp = g_object_get_data(G_OBJECT(tag), "link_url");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3692 if (tmp) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3693 g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3694 buf[sizeof(buf)-1] = '\0';
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3695 return buf;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3696 } else {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3697 return "";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3698 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3699 } else if (strncmp(name, "FORECOLOR ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3700 g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3701 return buf;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3702 } else if (strncmp(name, "BACKCOLOR ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3703 g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3704 return buf;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3705 } else if (strncmp(name, "FONT FACE ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3706 g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3707 return buf;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3708 } else if (strncmp(name, "FONT SIZE ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3709 g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3710 return buf;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3711 } else {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3712 return "";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3713 }
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3714 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3715
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3716 static const gchar *tag_to_html_end(GtkTextTag *tag)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3717 {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3718 const gchar *name;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3719
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3720 name = tag->name;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3721 g_return_val_if_fail(name != NULL, "");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3722
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3723 if (strcmp(name, "BOLD") == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3724 return "</b>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3725 } else if (strcmp(name, "ITALICS") == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3726 return "</i>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3727 } else if (strcmp(name, "UNDERLINE") == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3728 return "</u>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3729 } else if (strncmp(name, "LINK ", 5) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3730 return "</a>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3731 } else if (strncmp(name, "FORECOLOR ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3732 return "</font>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3733 } else if (strncmp(name, "BACKCOLOR ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3734 return "</font>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3735 } else if (strncmp(name, "FONT FACE ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3736 return "</font>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3737 } else if (strncmp(name, "FONT SIZE ", 10) == 0) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3738 return "</font>";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3739 } else {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3740 return "";
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3741 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3742 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3743
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3744 static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3745 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3746 return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) &&
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3747 !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) ||
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3748 gtk_text_iter_is_end(niter));
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3749 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3750
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3751 /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3752 * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3753 * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3754 * the actual text. Then check for tags that are toggled off and insert them, after checking the queue.
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8729
diff changeset
3755 * Finally, replace <, >, &, and " with their HTML equivalent.
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3756 */
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3757 char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3758 {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3759 gunichar c;
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3760 GtkTextIter iter, nextiter;
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3761 GString *str = g_string_new("");
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3762 GSList *tags, *sl;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3763 GQueue *q, *r;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3764 GtkTextTag *tag;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3765
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3766 q = g_queue_new();
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3767 r = g_queue_new();
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3768
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3769
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3770 gtk_text_iter_order(start, end);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3771 nextiter = iter = *start;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3772 gtk_text_iter_forward_char(&nextiter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3773
9071
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3774 /* First add the tags that are already in progress (we don't care about non-printing tags)*/
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3775 tags = gtk_text_iter_get_tags(start);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3776
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3777 for (sl = tags; sl; sl = sl->next) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3778 tag = sl->data;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3779 if (!gtk_text_iter_toggles_tag(start, GTK_TEXT_TAG(tag))) {
9071
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3780 if (strlen(tag_to_html_end(tag)) > 0)
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3781 g_string_append(str, tag_to_html_start(tag));
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3782 g_queue_push_tail(q, tag);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3783 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3784 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3785 g_slist_free(tags);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3786
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3787 while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3788
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3789 tags = gtk_text_iter_get_tags(&iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3790
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3791 for (sl = tags; sl; sl = sl->next) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3792 tag = sl->data;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3793 if (gtk_text_iter_begins_tag(&iter, GTK_TEXT_TAG(tag))) {
9071
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3794 if (strlen(tag_to_html_end(tag)) > 0)
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3795 g_string_append(str, tag_to_html_start(tag));
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3796 g_queue_push_tail(q, tag);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3797 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3798 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3799
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3800
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3801 if (c == 0xFFFC) {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3802 GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter);
9071
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3803 if (anchor) {
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3804 char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext");
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3805 if (text)
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3806 str = g_string_append(str, text);
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3807 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3808 } else if (c == '<') {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3809 str = g_string_append(str, "&lt;");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3810 } else if (c == '>') {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3811 str = g_string_append(str, "&gt;");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3812 } else if (c == '&') {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3813 str = g_string_append(str, "&amp;");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3814 } else if (c == '"') {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3815 str = g_string_append(str, "&quot;");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3816 } else if (c == '\n') {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3817 str = g_string_append(str, "<br>");
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3818 } else {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3819 str = g_string_append_unichar(str, c);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3820 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3821
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3822 tags = g_slist_reverse(tags);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3823 for (sl = tags; sl; sl = sl->next) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3824 tag = sl->data;
9071
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3825 /** don't worry about non-printing tags ending */
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3826 if (tag_ends_here(tag, &iter, &nextiter) && strlen(tag_to_html_end(tag)) > 0) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3827
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3828 GtkTextTag *tmp;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3829
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3830 while ((tmp = g_queue_pop_tail(q)) != tag) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3831 if (tmp == NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3832 break;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3833
9071
2233d33b2285 [gaim-migrate @ 9847]
Tim Ringenbach <marv@pidgin.im>
parents: 9037
diff changeset
3834 if (!tag_ends_here(tmp, &iter, &nextiter) && strlen(tag_to_html_end(tmp)) > 0)
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3835 g_queue_push_tail(r, tmp);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3836 g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tmp)));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3837 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3838
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3839 if (tmp == NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3840 gaim_debug_warning("gtkimhtml", "empty queue, more closing tags than open tags!\n");
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3841 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3842 g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tag)));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3843
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3844 while ((tmp = g_queue_pop_head(r))) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3845 g_string_append(str, tag_to_html_start(GTK_TEXT_TAG(tmp)));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3846 g_queue_push_tail(q, tmp);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3847 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3848 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3849 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3850
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3851 g_slist_free(tags);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3852 gtk_text_iter_forward_char(&iter);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3853 gtk_text_iter_forward_char(&nextiter);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3854 }
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3855
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3856 while ((tag = g_queue_pop_tail(q)))
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3857 g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tag)));
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3858
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3859 g_queue_free(q);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3860 g_queue_free(r);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3861 return g_string_free(str, FALSE);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3862 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3863
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
3864 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3865 {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3866 if (imhtml->edit.bold)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3867 gtk_imhtml_toggle_bold(imhtml);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3868
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3869 if (imhtml->edit.italic)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3870 gtk_imhtml_toggle_italic(imhtml);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3871
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3872 if (imhtml->edit.underline)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3873 gtk_imhtml_toggle_underline(imhtml);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3874
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3875 if (imhtml->edit.forecolor)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3876 gtk_imhtml_toggle_forecolor(imhtml, NULL);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3877
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3878 if (imhtml->edit.backcolor)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3879 gtk_imhtml_toggle_backcolor(imhtml, NULL);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3880
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3881 if (imhtml->edit.fontface)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3882 gtk_imhtml_toggle_fontface(imhtml, NULL);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3883
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3884 imhtml->edit.fontsize = 0;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3885
8719
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
3886 if (imhtml->edit.link)
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
3887 gtk_imhtml_toggle_link(imhtml, NULL);
513b8bbcc104 [gaim-migrate @ 9474]
Luke Schierer <lschiere@pidgin.im>
parents: 8707
diff changeset
3888
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
3889 gtk_text_buffer_remove_all_tags(imhtml->text_buffer, iter, iter);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3890
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3891 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3892
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3893 char *gtk_imhtml_get_markup(GtkIMHtml *imhtml)
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3894 {
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3895 GtkTextIter start, end;
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3896
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3897 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3898 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3899 return gtk_imhtml_get_markup_range(imhtml, &start, &end);
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3900 }
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3901
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3902 char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3903 {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3904 int i, j, lines;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3905 GtkTextIter start, end;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3906 char **ret;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3907
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3908 lines = gtk_text_buffer_get_line_count(imhtml->text_buffer);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3909 ret = g_new0(char *, lines + 1);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3910 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3911 end = start;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3912 gtk_text_iter_forward_to_line_end(&end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3913
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3914 for (i = 0, j = 0; i < lines; i++) {
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3915 ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3916 if (ret[j] != NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3917 j++;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3918 gtk_text_iter_forward_line(&start);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3919 end = start;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3920 gtk_text_iter_forward_to_line_end(&end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3921 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3922
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3923 return ret;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3924 }
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3925
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3926 char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop)
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3927 {
8519
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3928 GString *str = g_string_new("");
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3929 GtkTextIter iter, end;
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3930 gunichar c;
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3931
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3932 if (start == NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3933 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3934 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3935 iter = *start;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3936
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3937 if (stop == NULL)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3938 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3939 else
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3940 end = *stop;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3941
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3942 gtk_text_iter_order(&iter, &end);
8519
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3943
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3944 while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) {
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3945 if (c == 0xFFFC) {
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3946 GtkTextChildAnchor* anchor;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3947 char *text = NULL;
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3948
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3949 anchor = gtk_text_iter_get_child_anchor(&iter);
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3950 if (anchor)
8698
f36eee61c85f [gaim-migrate @ 9451]
Luke Schierer <lschiere@pidgin.im>
parents: 8693
diff changeset
3951 text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext");
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3952 if (text)
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8654
diff changeset
3953 str = g_string_append(str, text);
8519
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3954 } else {
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3955 g_string_append_unichar(str, c);
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3956 }
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3957 gtk_text_iter_forward_char(&iter);
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3958 }
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3959
f8ab826e11ad [gaim-migrate @ 9258]
Luke Schierer <lschiere@pidgin.im>
parents: 8516
diff changeset
3960 return g_string_free(str, FALSE);
8061
ea073d234191 [gaim-migrate @ 8749]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
3961 }
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3963 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f)
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3964 {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3965 g_return_if_fail(imhtml != NULL);
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3966 imhtml->funcs = f;
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8957
diff changeset
3967 }