annotate src/gtkimhtml.c @ 7821:ea8a104c053d

[gaim-migrate @ 8473] I think this probably would have helped me before I read the RFC committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 09 Dec 2003 16:56:25 +0000
parents 533419ef5569
children 3738e3ac6d88
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 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 2000, Eric Warmenhoven <warmenhoven@yahoo.com>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * under the terms of the GNU General Public License as published by
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
22 #ifdef HAVE_CONFIG_H
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
23 #include <config.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
24 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include "gtkimhtml.h"
7358
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
26 #include "gtksourceiter.h"
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <gtk/gtk.h>
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
28 #include <glib/gerror.h>
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
29 #include <gdk/gdkkeysyms.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <stdio.h>
4629
86fd0f6eaa1a [gaim-migrate @ 4920]
Mark Doliner <mark@kingant.net>
parents: 4612
diff changeset
33 #include <stdlib.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <math.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
35 #ifdef HAVE_LANGINFO_CODESET
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
36 #include <langinfo.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
37 #include <locale.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
38 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
40 #ifdef ENABLE_NLS
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
41 # include <libintl.h>
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
42 # define _(x) gettext(x)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
43 # ifdef gettext_noop
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
44 # define N_(String) gettext_noop (String)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
45 # else
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
46 # define N_(String) (String)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
47 # endif
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
48 #else
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
49 # define N_(String) (String)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
50 # define _(x) (x)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
51 #endif
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
52
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
53 #include <pango/pango-font.h>
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
54
5105
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
55 /* GTK+ < 2.2.2 hack, see ui.h for details. */
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
56 #ifndef GTK_WRAP_WORD_CHAR
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
57 #define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
58 #endif
4cfc49e31c2e [gaim-migrate @ 5468]
Luke Schierer <lschiere@pidgin.im>
parents: 5104
diff changeset
59
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
60 #define TOOLTIP_TIMEOUT 500
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
61
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
62 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml);
7787
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
63 void gtk_imhtml_close_tags(GtkIMHtml *imhtml);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
64
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
65 /* 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
66 * 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
67 #define MAX_FONT_SIZE 7
5367
fc0441fbf159 [gaim-migrate @ 5743]
Luke Schierer <lschiere@pidgin.im>
parents: 5293
diff changeset
68 #define POINT_SIZE(x) (options & GTK_IMHTML_USE_POINTSIZE ? x : _point_sizes [MIN ((x), MAX_FONT_SIZE) - 1])
3928
fb60cd7a2506 [gaim-migrate @ 4100]
Sean Egan <seanegan@gmail.com>
parents: 3922
diff changeset
69 static gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 };
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
70
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
71 enum {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
72 TARGET_HTML,
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
73 TARGET_UTF8_STRING,
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
74 TARGET_COMPOUND_TEXT,
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
75 TARGET_STRING,
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
76 TARGET_TEXT
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
77 };
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
78
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
79 GtkTargetEntry selection_targets[] = {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
80 { "text/html", 0, TARGET_HTML },
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
81 { "UTF8_STRING", 0, TARGET_UTF8_STRING },
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
82 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT },
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
83 { "STRING", 0, TARGET_STRING },
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
84 { "TEXT", 0, TARGET_TEXT}};
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
85
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
86 static GtkSmileyTree*
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
87 gtk_smiley_tree_new ()
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
88 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
89 return g_new0 (GtkSmileyTree, 1);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
90 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
91
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
92 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
93 gtk_smiley_tree_insert (GtkSmileyTree *tree,
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
94 GtkIMHtmlSmiley *smiley)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
95 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
96 GtkSmileyTree *t = tree;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
97 const gchar *x = smiley->smile;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
98
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
99 if (!strlen (x))
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
100 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
101
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
102 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
103 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
104 gint index;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
105
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
106 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
107 t->values = g_string_new ("");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
108
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
109 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
110 if (!pos) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
111 t->values = g_string_append_c (t->values, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
112 index = t->values->len - 1;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
113 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
114 t->children [index] = g_new0 (GtkSmileyTree, 1);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
115 } else
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7384
diff changeset
116 index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
117
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
118 t = t->children [index];
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
119
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
120 x++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
121 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
122
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
123 t->image = smiley;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
124 }
4041
3a36ec242415 [gaim-migrate @ 4249]
Sean Egan <seanegan@gmail.com>
parents: 4032
diff changeset
125
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
126
4264
f1876640e568 [gaim-migrate @ 4515]
Sean Egan <seanegan@gmail.com>
parents: 4263
diff changeset
127 void gtk_smiley_tree_destroy (GtkSmileyTree *tree)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
128 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
129 GSList *list = g_slist_append (NULL, tree);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
130
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
131 while (list) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
132 GtkSmileyTree *t = list->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
133 gint i;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
134 list = g_slist_remove(list, t);
7384
dc573236dc8b [gaim-migrate @ 7979]
Nathan Walp <nwalp@pidgin.im>
parents: 7371
diff changeset
135 if (t && t->values) {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
136 for (i = 0; i < t->values->len; i++)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
137 list = g_slist_append (list, t->children [i]);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
138 g_string_free (t->values, TRUE);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
139 g_free (t->children);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
140 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
141 g_free (t);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
142 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
143 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
144
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
145 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
146 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
147 GdkRectangle rect;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
148
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
149 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
150 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
151 GList *iter = GTK_IMHTML(widget)->scalables;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
152
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
153 while(iter){
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
154 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(iter->data);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
155 scale->scale(scale, rect.width, rect.height);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
156
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
157 iter = iter->next;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
158 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
159 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
160
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
161 widget->old_rect = rect;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
162 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
163 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
164
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
165 static gint
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
166 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
167 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
168 PangoLayout *layout;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
169
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
170 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
171
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
172 layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
173
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
174 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
175 GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window,
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
176 "tooltip", 0, 0, -1, -1);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
177
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
178 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
179 FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
180
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
181 g_object_unref(layout);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
182 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
183 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
184
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
185 static gint
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
186 gtk_imhtml_tip (gpointer data)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
187 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
188 GtkIMHtml *imhtml = data;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
189 PangoFontMetrics *font;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
190 PangoLayout *layout;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
191
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
192 gint gap, x, y, h, w, scr_w, baseline_skip;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
193
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
194 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
195
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
196 if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
197 imhtml->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
198 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
199 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
200
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
201 if (imhtml->tip_window){
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
202 gtk_widget_destroy (imhtml->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
203 imhtml->tip_window = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
204 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
205
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
206 imhtml->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
207 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
208 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
209 gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
210 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips");
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
211 g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event",
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
212 G_CALLBACK (gtk_imhtml_tip_paint), imhtml);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
213
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
214 gtk_widget_ensure_style (imhtml->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
215 layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
216 font = pango_font_get_metrics(pango_context_load_font(pango_layout_get_context(layout),
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
217 imhtml->tip_window->style->font_desc),
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
218 NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
219
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
220
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
221 pango_layout_get_pixel_size(layout, &scr_w, NULL);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
222 gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font) +
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
223 pango_font_metrics_get_descent(font))/ 4);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
224
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
225 if (gap < 2)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
226 gap = 2;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
227 baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font) +
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
228 pango_font_metrics_get_descent(font));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
229 w = 8 + scr_w;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
230 h = 8 + baseline_skip;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
231
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
232 gdk_window_get_pointer (NULL, &x, &y, NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
233 if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml)))
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
234 y += GTK_WIDGET(imhtml)->allocation.y;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
235
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
236 scr_w = gdk_screen_width();
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
237
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
238 x -= ((w >> 1) + 4);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
239
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
240 if ((x + w) > scr_w)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
241 x -= (x + w) - scr_w;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
242 else if (x < 0)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
243 x = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
244
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
245 y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font) +
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
246 pango_font_metrics_get_descent(font));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
247
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
248 gtk_widget_set_size_request (imhtml->tip_window, w, h);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
249 gtk_widget_show (imhtml->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
250 gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
251
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
252 pango_font_metrics_unref(font);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
253 g_object_unref(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 return 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
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
258 gboolean gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data)
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
259 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
260 GtkTextIter iter;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
261 GdkWindow *win = event->window;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
262 int x, y;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
263 char *tip = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
264 GSList *tags = NULL, *templist = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
265 gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
266 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
267 event->x, event->y, &x, &y);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
268 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
269 tags = gtk_text_iter_get_tags(&iter);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
270
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
271 templist = tags;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
272 while (templist) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
273 GtkTextTag *tag = templist->data;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
274 tip = g_object_get_data(G_OBJECT(tag), "link_url");
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
275 if (tip)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
276 break;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
277 templist = templist->next;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
278 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
279
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
280 if (GTK_IMHTML(imhtml)->tip) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
281 if ((tip == GTK_IMHTML(imhtml)->tip)) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
282 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
283 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
284 /* 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
285 if (GTK_IMHTML(imhtml)->tip_window) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
286 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
287 GTK_IMHTML(imhtml)->tip_window = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
288 }
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
289 if (GTK_IMHTML(imhtml)->editable)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
290 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->text_cursor);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
291 else
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
292 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
293 if (GTK_IMHTML(imhtml)->tip_timer)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
294 g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
295 GTK_IMHTML(imhtml)->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
296 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
297
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
298 if(tip){
7709
a1d913ecd0f6 [gaim-migrate @ 8354]
Sean Egan <seanegan@gmail.com>
parents: 7707
diff changeset
299 if (!GTK_IMHTML(imhtml)->editable)
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
300 gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
301 GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT,
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
302 gtk_imhtml_tip, imhtml);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
303 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
304
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
305 GTK_IMHTML(imhtml)->tip = tip;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
306 g_slist_free(tags);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
307 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
308 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
309
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
310 gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
311 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
312 /* 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
313 if (GTK_IMHTML(imhtml)->tip_window) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
314 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
315 GTK_IMHTML(imhtml)->tip_window = NULL;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
316 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
317 if (GTK_IMHTML(imhtml)->tip_timer) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
318 g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
319 GTK_IMHTML(imhtml)->tip_timer = 0;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
320 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
321 if (GTK_IMHTML(imhtml)->editable)
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
322 gdk_window_set_cursor(event->window, GTK_IMHTML(imhtml)->text_cursor);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
323 else
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
324 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
325
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
326 /* propogate the event normally */
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
327 return FALSE;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
328 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
329
6066
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
330 /*
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
331 * XXX - This should be removed eventually.
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
332 *
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
333 * This function exists to work around a gross bug in GtkTextView.
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
334 * 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
335 * el program go boom.
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
336 *
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
337 * 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
338 * http://bugzilla.gnome.org/show_bug.cgi?id=107939
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
339 */
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
340 gboolean gtk_key_pressed_cb(GtkWidget *imhtml, GdkEventKey *event, gpointer data)
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
341 {
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
342 if (event->state & GDK_CONTROL_MASK)
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
343 switch (event->keyval) {
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
344 case 'a':
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
345 return TRUE;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
346 break;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
347
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
348 case GDK_Home:
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
349 return TRUE;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
350 break;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
351
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
352 case GDK_End:
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
353 return TRUE;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
354 break;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
355 }
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
356
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
357 return FALSE;
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
358 }
c99959f1bb73 [gaim-migrate @ 6516]
Mark Doliner <mark@kingant.net>
parents: 6056
diff changeset
359
7404
d889a99e0eb1 [gaim-migrate @ 8000]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
360 #if GTK_CHECK_VERSION(2,2,0)
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
361 static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
362 GtkTextIter start, end;
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
363 GtkTextMark *sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
364 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
7779
de9a47ff006a [gaim-migrate @ 8424]
Sean Egan <seanegan@gmail.com>
parents: 7778
diff changeset
365 char *text;
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
366 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
367 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
368
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
369
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
370 if (info == TARGET_HTML) {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
371 int len;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
372 GString *str = g_string_new(NULL);
7779
de9a47ff006a [gaim-migrate @ 8424]
Sean Egan <seanegan@gmail.com>
parents: 7778
diff changeset
373 text = gtk_imhtml_get_markup_range(imhtml, &start, &end);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
374
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
375 /* Mozilla asks that we start our text/html with the Unicode byte order mark */
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
376 str = g_string_append_unichar(str, 0xfeff);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
377 str = g_string_append(str, text);
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
378 str = g_string_append_unichar(str, 0x0000);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
379 char *selection = g_convert(str->str, str->len, "UCS-2", "UTF-8", NULL, &len, NULL);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
380 gtk_selection_data_set (selection_data, gdk_atom_intern("text/html", FALSE), 16, selection, len);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
381 g_string_free(str, TRUE);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
382 g_free(selection);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
383 } else {
7787
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
384 text = gtk_text_buffer_get_text(imhtml->text_buffer, &start, &end, FALSE);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
385 gtk_selection_data_set_text(selection_data, text, strlen(text));
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
386 }
7779
de9a47ff006a [gaim-migrate @ 8424]
Sean Egan <seanegan@gmail.com>
parents: 7778
diff changeset
387 g_free(text);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
388 }
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
389
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
390 static void gtk_imhtml_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml)
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
391 {
7750
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
392 GtkTextIter insert;
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
393 GtkTextIter selection_bound;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
394
7750
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
395 gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert,
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
396 gtk_text_buffer_get_mark (imhtml->text_buffer, "insert"));
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
397 gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound,
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
398 gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"));
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
399
7750
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
400 if (!gtk_text_iter_equal (&insert, &selection_bound))
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
401 gtk_text_buffer_move_mark (imhtml->text_buffer,
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
402 gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"),
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
403 &insert);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
404 }
7742
6cd69aa58253 [gaim-migrate @ 8387]
Sean Egan <seanegan@gmail.com>
parents: 7740
diff changeset
405
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
406 static void copy_clipboard_cb(GtkIMHtml *imhtml, GtkClipboard *clipboard)
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
407 {
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
408 gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
409 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
410 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
7750
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
411 (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
412
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
413 g_signal_stop_emission_by_name(imhtml, "copy-clipboard");
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
414 }
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
415
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
416 static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data)
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
417 {
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
418 char *text;
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
419 guint16 c;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
420 GtkIMHtml *imhtml = data;
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
421
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
422 if (selection_data->length < 0) {
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
423 text = gtk_clipboard_wait_for_text(clipboard);
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
424 } else {
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
425 text = g_malloc((selection_data->format / 8) * selection_data->length);
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
426 memcpy(text, selection_data->data, selection_data->length * (selection_data->format / 8));
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
427 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
428
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
429 memcpy (&c, text, 2);
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
430 if (c == 0xfeff) {
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
431 /* This is UCS2 */
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
432 char *utf8 = g_convert(text+2, (selection_data->length * (selection_data->format / 8)) - 2, "UTF-8", "UCS-2", NULL, NULL, NULL);
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
433 g_free(text);
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
434 text = utf8;
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
435 }
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
436 gtk_imhtml_close_tags(imhtml);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
437 gtk_imhtml_append_text_with_images(imhtml, text, GTK_IMHTML_NO_NEWLINE, NULL);
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
438 }
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
439
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
440
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
441 static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah)
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
442 {
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
443
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
444 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
445 gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE),
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
446 paste_received_cb, imhtml);
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
447 g_signal_stop_emission_by_name(imhtml, "paste-clipboard");
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
448 }
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
449
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
450 static gboolean button_release_cb(GtkIMHtml *imhtml, GdkEventButton event, gpointer the_foibles_of_man)
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
451 {
7750
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
452 GtkClipboard *clipboard;
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
453 if (event.button == 1) {
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
454 if ((clipboard = gtk_widget_get_clipboard (GTK_WIDGET (imhtml),
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
455 GDK_SELECTION_PRIMARY)))
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
456 gtk_text_buffer_remove_selection_clipboard (imhtml->text_buffer, clipboard);
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
457 gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY),
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
458 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
459 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
460 (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, G_OBJECT(imhtml));
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
461 }
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
462 return FALSE;
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
463 }
7404
d889a99e0eb1 [gaim-migrate @ 8000]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
464 #endif
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
465
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
466
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
467 static GtkTextViewClass *parent_class = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
468
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
469 /* GtkIMHtml has one signal--URL_CLICKED */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 LAST_SIGNAL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
476 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
477 gtk_imhtml_finalize (GObject *object)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
478 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
479 GtkIMHtml *imhtml = GTK_IMHTML(object);
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
480 GList *scalables;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
481
4138
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
482 g_hash_table_destroy(imhtml->smiley_data);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
483 gtk_smiley_tree_destroy(imhtml->default_smilies);
4138
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
484 gdk_cursor_unref(imhtml->hand_cursor);
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
485 gdk_cursor_unref(imhtml->arrow_cursor);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
486 gdk_cursor_unref(imhtml->text_cursor);
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
487 if(imhtml->tip_window){
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
488 gtk_widget_destroy(imhtml->tip_window);
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
489 }
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
490 if(imhtml->tip_timer)
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
491 gtk_timeout_remove(imhtml->tip_timer);
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
492
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
493 for(scalables = imhtml->scalables; scalables; scalables = scalables->next) {
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
494 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(scalables->data);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
495 scale->free(scale);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
496 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
497
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
498 g_list_free(imhtml->scalables);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
499 G_OBJECT_CLASS(parent_class)->finalize (object);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
500 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
502 /* Boring GTK stuff */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
503 static void gtk_imhtml_class_init (GtkIMHtmlClass *class)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
505 GtkObjectClass *object_class;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
506 GObjectClass *gobject_class;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
507 object_class = (GtkObjectClass*) class;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
508 gobject_class = (GObjectClass*) class;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
509 parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
510 signals[URL_CLICKED] = g_signal_new("url_clicked",
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
511 G_TYPE_FROM_CLASS(gobject_class),
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
512 G_SIGNAL_RUN_FIRST,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
513 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked),
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
514 NULL,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
515 0,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
516 g_cclosure_marshal_VOID__POINTER,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
517 G_TYPE_NONE, 1,
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
518 G_TYPE_POINTER);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
519 gobject_class->finalize = gtk_imhtml_finalize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
522 static void gtk_imhtml_init (GtkIMHtml *imhtml)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
524 GtkTextIter iter;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
525 imhtml->text_buffer = gtk_text_buffer_new(NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
526 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
527 imhtml->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, FALSE);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
528 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
529 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
530 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
531 /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
532 /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
533
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
534 /* These tags will be used often and can be reused--we create them on init and then apply them by name
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
535 * other tags (color, size, face, etc.) will have to be created and applied dynamically */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
536 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
537 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
538 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
539 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
540 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
541 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
542 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
543 gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL);
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
544 gtk_text_buffer_create_tag(imhtml->text_buffer, "LINK", "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
545 /* 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
546 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
547 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
548 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
549
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
550 imhtml->show_smileys = TRUE;
6124
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
551 imhtml->show_comments = TRUE;
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
552
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
553 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
554 g_free, (GDestroyNotify)gtk_smiley_tree_destroy);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
555 imhtml->default_smilies = gtk_smiley_tree_new();
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
556
4944
5fe846b7603f [gaim-migrate @ 5278]
Sean Egan <seanegan@gmail.com>
parents: 4926
diff changeset
557 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
558 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
559 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
560 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
561 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml);
7404
d889a99e0eb1 [gaim-migrate @ 8000]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
562 #if GTK_CHECK_VERSION(2,2,0)
7353
dc35b4a42fea [gaim-migrate @ 7944]
Sean Egan <seanegan@gmail.com>
parents: 7346
diff changeset
563 g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL);
7766
9d6ba1c44cb7 [gaim-migrate @ 8411]
Sean Egan <seanegan@gmail.com>
parents: 7754
diff changeset
564 g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL);
7346
15155dbc768a [gaim-migrate @ 7937]
Sean Egan <seanegan@gmail.com>
parents: 7344
diff changeset
565 g_signal_connect(G_OBJECT(imhtml), "button-release-event", G_CALLBACK(button_release_cb), imhtml);
7404
d889a99e0eb1 [gaim-migrate @ 8000]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
566 #endif
4944
5fe846b7603f [gaim-migrate @ 5278]
Sean Egan <seanegan@gmail.com>
parents: 4926
diff changeset
567 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
568
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
569 imhtml->tip = NULL;
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
570 imhtml->tip_timer = 0;
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
571 imhtml->tip_window = NULL;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
572
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
573 imhtml->edit.bold = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
574 imhtml->edit.italic = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
575 imhtml->edit.underline = NULL;
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
576 imhtml->edit.forecolor = NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
577 imhtml->edit.backcolor = NULL;
7717
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
578 imhtml->edit.fontface = NULL;
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
579 imhtml->edit.sizespan = NULL;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
580 imhtml->edit.fontsize = 3;
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
581
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
582 imhtml->format_spans = NULL;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
583
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
584 imhtml->scalables = NULL;
7750
14cc6614af93 [gaim-migrate @ 8395]
Sean Egan <seanegan@gmail.com>
parents: 7749
diff changeset
585
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
586 gtk_imhtml_set_editable(imhtml, FALSE);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
587
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
588 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
589
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
590 GtkWidget *gtk_imhtml_new(void *a, void *b)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591 {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
592 return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
595 GType gtk_imhtml_get_type()
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
597 static GType imhtml_type = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599 if (!imhtml_type) {
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
600 static const GTypeInfo imhtml_info = {
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
601 sizeof(GtkIMHtmlClass),
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
602 NULL,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
603 NULL,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
604 (GClassInitFunc) gtk_imhtml_class_init,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
605 NULL,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
606 NULL,
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 sizeof (GtkIMHtml),
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
608 0,
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
609 (GInstanceInitFunc) gtk_imhtml_init
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 };
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
611
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
612 imhtml_type = g_type_register_static(gtk_text_view_get_type(),
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4630
diff changeset
613 "GtkIMHtml", &imhtml_info, 0);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
619 struct url_data {
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
620 GObject *object;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
621 gchar *url;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
622 };
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
623
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
624 static void url_open(GtkWidget *w, struct url_data *data) {
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
625 if(!data) return;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
626 g_signal_emit(data->object, signals[URL_CLICKED], 0, data->url);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
627
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
628 g_object_unref(data->object);
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
629 g_free(data->url);
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
630 g_free(data);
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
631 }
5582
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
632
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
633 static void url_copy(GtkWidget *w, gchar *url) {
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
634 GtkClipboard *clipboard;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
635
5293
ead927e2543f [gaim-migrate @ 5665]
Christian Hammond <chipx86@chipx86.com>
parents: 5282
diff changeset
636 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
637 gtk_clipboard_set_text(clipboard, url, -1);
5582
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
638
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
639 clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
e2f2d8857f9f [gaim-migrate @ 5986]
Luke Schierer <lschiere@pidgin.im>
parents: 5367
diff changeset
640 gtk_clipboard_set_text(clipboard, url, -1);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
641 }
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
642
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
643 /* The callback for an event on a link tag. */
5091
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
644 gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, char *url) {
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
645 GdkEventButton *event_button = (GdkEventButton *) event;
7801
9db4ec5e6bca [gaim-migrate @ 8447]
Sean Egan <seanegan@gmail.com>
parents: 7800
diff changeset
646 if (GTK_IMHTML(imhtml)->editable)
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
647 return FALSE;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
648 if (event->type == GDK_BUTTON_RELEASE) {
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
649 if (event_button->button == 1) {
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
650 GtkTextIter start, end;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
651 /* we shouldn't open a URL if the user has selected something: */
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
652 gtk_text_buffer_get_selection_bounds(
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
653 gtk_text_iter_get_buffer(arg2), &start, &end);
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
654 if(gtk_text_iter_get_offset(&start) !=
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
655 gtk_text_iter_get_offset(&end))
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
656 return FALSE;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
657
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
658 /* A link was clicked--we emit the "url_clicked" signal
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
659 * with the URL as the argument */
5091
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
660 g_signal_emit(imhtml, signals[URL_CLICKED], 0, url);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
661 return FALSE;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
662 } else if(event_button->button == 3) {
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
663 GtkWidget *img, *item, *menu;
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
664 struct url_data *tempdata = g_new(struct url_data, 1);
5091
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
665 tempdata->object = g_object_ref(imhtml);
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
666 tempdata->url = g_strdup(url);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
667
5091
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
668 /* 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
669 if (GTK_IMHTML(imhtml)->tip_window) {
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
670 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window);
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
671 GTK_IMHTML(imhtml)->tip_window = NULL;
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
672 }
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
673 if (GTK_IMHTML(imhtml)->tip_timer) {
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
674 g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
675 GTK_IMHTML(imhtml)->tip_timer = 0;
04ded2f7253c [gaim-migrate @ 5453]
Luke Schierer <lschiere@pidgin.im>
parents: 5046
diff changeset
676 }
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
677 if (GTK_IMHTML(imhtml)->editable)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
678 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
679 else
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
680 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
681 menu = gtk_menu_new();
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
682
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
683 /* buttons and such */
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
684
7140
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
685 if (!strncmp(url, "mailto:", 7))
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
686 {
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
687 /* Copy E-Mail Address */
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
688 img = gtk_image_new_from_stock(GTK_STOCK_COPY,
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
689 GTK_ICON_SIZE_MENU);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
690 item = gtk_image_menu_item_new_with_mnemonic(
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
691 _("_Copy E-Mail Address"));
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
692 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
693 g_signal_connect(G_OBJECT(item), "activate",
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
694 G_CALLBACK(url_copy), url + 7);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
695 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
696 }
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
697 else
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
698 {
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
699 /* Copy Link Location */
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
700 img = gtk_image_new_from_stock(GTK_STOCK_COPY,
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
701 GTK_ICON_SIZE_MENU);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
702 item = gtk_image_menu_item_new_with_mnemonic(
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
703 _("_Copy Link Location"));
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
704 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
705 g_signal_connect(G_OBJECT(item), "activate",
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
706 G_CALLBACK(url_copy), url);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
707 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
708
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
709 /* Open Link in Browser */
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
710 img = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO,
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
711 GTK_ICON_SIZE_MENU);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
712 item = gtk_image_menu_item_new_with_mnemonic(
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
713 _("_Open Link in Browser"));
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
714 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
715 g_signal_connect(G_OBJECT(item), "activate",
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
716 G_CALLBACK(url_open), tempdata);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
717 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
718 }
48cc5d5d5a6c [gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
719
4756
85637881b342 [gaim-migrate @ 5073]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
720
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
721 gtk_widget_show_all(menu);
4756
85637881b342 [gaim-migrate @ 5073]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
722 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
85637881b342 [gaim-migrate @ 5073]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
723 event_button->button, event_button->time);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4740
diff changeset
724
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
725 return TRUE;
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
726 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 }
4417
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
728 if(event->type == GDK_BUTTON_PRESS && event_button->button == 3)
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
729 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
730 be caught by the regular GtkTextView menu */
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
731 else
fff9c1292fa1 [gaim-migrate @ 4690]
Sean Egan <seanegan@gmail.com>
parents: 4371
diff changeset
732 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
733 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
735 /* this isn't used yet
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
736 static void
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
737 gtk_smiley_tree_remove (GtkSmileyTree *tree,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
738 GtkIMHtmlSmiley *smiley)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
739 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
740 GtkSmileyTree *t = tree;
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
741 const gchar *x = smiley->smile;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
742 gint len = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
743
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
744 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
745 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
746
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
747 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
748 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
749
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
750 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
751 if (pos)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
752 t = t->children [(int) pos - (int) t->values->str];
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
753 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
754 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
755
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
756 x++; len++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
757 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
758
4141
ccec4fde84f4 [gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents: 4140
diff changeset
759 if (t->image) {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
760 t->image = NULL;
4141
ccec4fde84f4 [gaim-migrate @ 4359]
Christian Hammond <chipx86@chipx86.com>
parents: 4140
diff changeset
761 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
762 }
4298
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
763 */
cddb50734169 [gaim-migrate @ 4552]
Sean Egan <seanegan@gmail.com>
parents: 4288
diff changeset
764
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
765
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
766 static gint
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
767 gtk_smiley_tree_lookup (GtkSmileyTree *tree,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
768 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
769 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
770 GtkSmileyTree *t = tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
771 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
772 gint len = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
773
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
774 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
775 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
776
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
777 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
778 break;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
779
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
780 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
781 if (pos)
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
782 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
783 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
784 break;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
785
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
786 x++; len++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
787 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
788
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
789 if (t->image)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
790 return len;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
791
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
792 return 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
793 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
794
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
795 void
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
796 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
797 gchar *sml,
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
798 GtkIMHtmlSmiley *smiley)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
799 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
800 GtkSmileyTree *tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
801 g_return_if_fail (imhtml != NULL);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
802 g_return_if_fail (GTK_IS_IMHTML (imhtml));
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
803
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
804 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
805 tree = imhtml->default_smilies;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
806 else if ((tree = g_hash_table_lookup(imhtml->smiley_data, sml))) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
807 } else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
808 tree = gtk_smiley_tree_new();
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
809 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
810 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
811
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
812 gtk_smiley_tree_insert (tree, smiley);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
813 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
814
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
815 static gboolean
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
816 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
817 GSList *fonts,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
818 const gchar *text,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
819 gint *len)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
820 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
821 GtkSmileyTree *tree;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
822 GtkIMHtmlFontDetail *font;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
823 char *sml = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
824
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
825 if (fonts) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
826 font = fonts->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
827 sml = font->sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
828 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
829
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
830 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
831 tree = imhtml->default_smilies;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
832 else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
833 tree = g_hash_table_lookup(imhtml->smiley_data, sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
834 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
835 if (tree == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
836 return FALSE;
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
837
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
838 *len = gtk_smiley_tree_lookup (tree, text);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
839 return (*len > 0);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
840 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
841
6814
782907a6ae65 [gaim-migrate @ 7354]
Christian Hammond <chipx86@chipx86.com>
parents: 6648
diff changeset
842 GdkPixbufAnimation *
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
843 gtk_smiley_tree_image (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
844 const gchar *sml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
845 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
846 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
847 GtkSmileyTree *t;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
848 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
849 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
850 t = imhtml->default_smilies;
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
851 else
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
852 t = g_hash_table_lookup(imhtml->smiley_data, sml);
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
853
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
854
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
855 if (t == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
856 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
857
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
858 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
859 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
860
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
861 if (!t->values) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
862 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
863 }
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
864
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
865 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
866 if (pos) {
7371
2ec21bff351b [gaim-migrate @ 7966]
Nathan Walp <nwalp@pidgin.im>
parents: 7358
diff changeset
867 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
868 } else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
869 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
870 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
871 x++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
872 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
873
4263
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
874 if (!t->image->icon)
6814
782907a6ae65 [gaim-migrate @ 7354]
Christian Hammond <chipx86@chipx86.com>
parents: 6648
diff changeset
875 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
876
74f65a3d2a1f [gaim-migrate @ 4514]
Sean Egan <seanegan@gmail.com>
parents: 4253
diff changeset
877 return t->image->icon;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
878 }
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
879 #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
880 *tag = g_strndup (string, strlen (x)); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
881 *len = strlen (x) + 1; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
882 return TRUE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
883 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
884 (*type)++
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
886 #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
887 const gchar *c = string + strlen (x " "); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
888 gchar e = '"'; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
889 gboolean quote = FALSE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
890 while (*c) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
891 if (*c == '"' || *c == '\'') { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
892 if (quote && (*c == e)) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
893 quote = !quote; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
894 else if (!quote) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
895 quote = !quote; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
896 e = *c; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
897 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
898 } else if (!quote && (*c == '>')) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
899 break; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
900 c++; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
901 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
902 if (*c) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
903 *tag = g_strndup (string, c - string); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
904 *len = c - string + 1; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
905 return TRUE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
906 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
907 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
908 (*type)++
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
911 static gboolean
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
912 gtk_imhtml_is_amp_escape (const gchar *string,
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
913 gchar **replace,
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
914 gint *length)
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
915 {
7287
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
916 static char buf[7];
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
917 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
918 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
919 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
920
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
921 if (!g_ascii_strncasecmp (string, "&amp;", 5)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
922 *replace = "&";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
923 *length = 5;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
924 } else if (!g_ascii_strncasecmp (string, "&lt;", 4)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
925 *replace = "<";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
926 *length = 4;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
927 } else if (!g_ascii_strncasecmp (string, "&gt;", 4)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
928 *replace = ">";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
929 *length = 4;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
930 } else if (!g_ascii_strncasecmp (string, "&nbsp;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
931 *replace = " ";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
932 *length = 6;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
933 } else if (!g_ascii_strncasecmp (string, "&copy;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
934 *replace = "©";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
935 *length = 6;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
936 } else if (!g_ascii_strncasecmp (string, "&quot;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
937 *replace = "\"";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
938 *length = 6;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
939 } else if (!g_ascii_strncasecmp (string, "&reg;", 5)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
940 *replace = "®";
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
941 *length = 5;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
942 } else if (!g_ascii_strncasecmp (string, "&apos;", 6)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
943 *replace = "\'";
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
944 *length = 6;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
945 } else if (*(string + 1) == '#') {
2022
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
946 guint pound = 0;
3004
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 3000
diff changeset
947 if ((sscanf (string, "&#%u;", &pound) == 1) && pound != 0) {
7287
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
948 int buflen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
949 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
950 return FALSE;
7287
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
951 buflen = g_unichar_to_utf8((gunichar)pound, buf);
3a41c3f80228 [gaim-migrate @ 7868]
Nathan Walp <nwalp@pidgin.im>
parents: 7281
diff changeset
952 buf[buflen] = '\0';
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
953 *replace = buf;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
954 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
955 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
956 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
957 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
958 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
959 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
960 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
961 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
962 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
963
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
964 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
965 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
966
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
967 static gboolean
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
968 gtk_imhtml_is_tag (const gchar *string,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
969 gchar **tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
970 gint *len,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
971 gint *type)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
972 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
973 *type = 1;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
974
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
975 if (!strchr (string, '>'))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
976 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
977
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
978 VALID_TAG ("B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
979 VALID_TAG ("BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
980 VALID_TAG ("/B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
981 VALID_TAG ("/BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
982 VALID_TAG ("I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
983 VALID_TAG ("ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
984 VALID_TAG ("/I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
985 VALID_TAG ("/ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
986 VALID_TAG ("U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
987 VALID_TAG ("UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
988 VALID_TAG ("/U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
989 VALID_TAG ("/UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
990 VALID_TAG ("S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
991 VALID_TAG ("STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
992 VALID_TAG ("/S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
993 VALID_TAG ("/STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
994 VALID_TAG ("SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
995 VALID_TAG ("/SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
996 VALID_TAG ("SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
997 VALID_TAG ("/SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
998 VALID_TAG ("PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
999 VALID_TAG ("/PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1000 VALID_TAG ("TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1001 VALID_TAG ("/TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1002 VALID_TAG ("BR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1003 VALID_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1004 VALID_TAG ("/FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1005 VALID_TAG ("/A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1006 VALID_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1007 VALID_TAG ("/P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1008 VALID_TAG ("H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1009 VALID_TAG ("/H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1010 VALID_TAG ("HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1011 VALID_TAG ("/HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1012 VALID_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1013 VALID_TAG ("/BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1014 VALID_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1015 VALID_TAG ("HEAD");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1016 VALID_TAG ("/HEAD");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1017 VALID_TAG ("BINARY");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1018 VALID_TAG ("/BINARY");
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1019
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1020 VALID_OPT_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1021 VALID_OPT_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1022 VALID_OPT_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1023 VALID_OPT_TAG ("A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1024 VALID_OPT_TAG ("IMG");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1025 VALID_OPT_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1026 VALID_OPT_TAG ("H3");
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1027 VALID_OPT_TAG ("HTML");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1028
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1029 VALID_TAG ("CITE");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1030 VALID_TAG ("/CITE");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1031 VALID_TAG ("EM");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1032 VALID_TAG ("/EM");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1033 VALID_TAG ("STRONG");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1034 VALID_TAG ("/STRONG");
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1035
5104
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1036 VALID_OPT_TAG ("SPAN");
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1037 VALID_TAG ("/SPAN");
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5118
diff changeset
1038 VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1039 VALID_TAG ("IMG");
5104
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1040
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1041 if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) {
2954
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
1042 gchar *e = strstr (string + strlen("!--"), "-->");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1043 if (e) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1044 *len = e - string + strlen ("-->");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1045 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->"));
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1046 return TRUE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1047 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1048 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1049
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1050 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1051 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1052
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1053 static gchar*
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1054 gtk_imhtml_get_html_opt (gchar *tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1055 const gchar *opt)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1056 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1057 gchar *t = tag;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1058 gchar *e, *a;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1059 gchar *val;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1060 gint len;
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1061 gchar *c;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1062 GString *ret;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1063
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1064 while (g_ascii_strncasecmp (t, opt, strlen (opt))) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1065 gboolean quote = FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1066 if (*t == '\0') break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1067 while (*t && !((*t == ' ') && !quote)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1068 if (*t == '\"')
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1069 quote = ! quote;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1070 t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1071 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1072 while (*t && (*t == ' ')) t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1073 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1074
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4764
diff changeset
1075 if (!g_ascii_strncasecmp (t, opt, strlen (opt))) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1076 t += strlen (opt);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1077 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1078 return NULL;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1079 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1080
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1081 if ((*t == '\"') || (*t == '\'')) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1082 e = a = ++t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1083 while (*e && (*e != *(t - 1))) e++;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1084 if (*e == '\0') {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1085 return NULL;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1086 } else
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1087 val = g_strndup(a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1088 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1089 e = a = t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1090 while (*e && !isspace ((gint) *e)) e++;
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1091 val = g_strndup(a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1092 }
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1093
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1094 ret = g_string_new("");
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1095 e = val;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1096 while(*e) {
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1097 if(gtk_imhtml_is_amp_escape(e, &c, &len)) {
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1098 ret = g_string_append(ret, c);
5177
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1099 e += len;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1100 } else {
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1101 ret = g_string_append_c(ret, *e);
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1102 e++;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1103 }
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1104 }
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1105
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1106 g_free(val);
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1107 val = ret->str;
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1108 g_string_free(ret, FALSE);
1c739f2ce94f [gaim-migrate @ 5541]
Nathan Walp <nwalp@pidgin.im>
parents: 5174
diff changeset
1109 return val;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1110 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1111
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1112
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1113 typedef enum {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1114 NEW_TEXT_BIT,
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1115 NEW_COMMENT_BIT,
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1116 NEW_SCALABLE_BIT
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1117 } GtkIMHtmlBitType;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1118
7787
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
1119 static inline void new_bit(GtkIMHtml *imhtml, GtkTextIter *iter, GtkIMHtmlBitType x, char *ws, int *wpos)
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1120 {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1121 GtkTextMark *mark2;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1122 GtkTextIter siter;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1123 GtkIMHtmlScalable *scalable = NULL;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1124
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1125 ws [*wpos] = '\0';
7787
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
1126 mark2 = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1127 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, -1);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1128
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1129 gtk_text_buffer_delete_mark(imhtml->text_buffer, mark2);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1130 /*if (bold)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1131 gtk
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1132 if (italics) \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1133 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1134 if (underline) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1135 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1136 if (strike) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1137 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1138 if (sub) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1139 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "SUB", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1140 if (sup) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1141 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "SUP", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1142 if (pre) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1143 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "PRE", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1144 if (bg) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1145 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", bg, NULL); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1146 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1147 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1148 if (fonts) { \
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1149 GtkIMHtmlFontDetail *fd = fonts->data; \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1150 if (fd->fore) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1151 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", fd->fore, NULL); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1152 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1153 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1154 if (fd->back) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1155 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", fd->back, NULL); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1156 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1157 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1158 if (fd->face) { \
6648
adf49a9bb9a0 [gaim-migrate @ 7173]
Luke Schierer <lschiere@pidgin.im>
parents: 6478
diff changeset
1159 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "family", fd->face, NULL); \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1160 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1161 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1162 if (fd->size) { \
5118
c4664c2bfbf8 [gaim-migrate @ 5481]
Luke Schierer <lschiere@pidgin.im>
parents: 5117
diff changeset
1163 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "size-points", (double)POINT_SIZE(fd->size), NULL); \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1164 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1165 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1166 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1167 if (url) { \
7732
31fd796d3909 [gaim-migrate @ 8377]
Sean Egan <seanegan@gmail.com>
parents: 7729
diff changeset
1168 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "LINK", &siter, &iter); \
31fd796d3909 [gaim-migrate @ 8377]
Sean Egan <seanegan@gmail.com>
parents: 7729
diff changeset
1169 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); \
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1170 \
7732
31fd796d3909 [gaim-migrate @ 8377]
Sean Egan <seanegan@gmail.com>
parents: 7729
diff changeset
1171 g_object_set_data(G_OBJECT(texttag), "link_url", g_strdup(url)); \
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1172 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1173 } \
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1174 */
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1175 *wpos = 0;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1176 ws[0] = 0;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1177 gtk_text_buffer_get_end_iter(imhtml->text_buffer, iter);
7787
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
1178 if (x == NEW_SCALABLE_BIT) {
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
1179 GdkRectangle rect;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1180
7787
666f672a869a [gaim-migrate @ 8432]
Nathan Walp <nwalp@pidgin.im>
parents: 7779
diff changeset
1181 }
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1182 }
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1183
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1184 GString* gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml,
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1185 const gchar *text,
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1186 GtkIMHtmlOptions options,
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1187 GSList *images)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 {
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1189 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1190 GtkTextIter insert;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1191 gint pos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1192 GString *str = NULL;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1193 GtkTextIter iter, siter;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1194 GtkTextMark *mark, *mark2;
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
1195 GtkTextTag *texttag = NULL;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1196 gchar *ws;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1197 gchar *tag;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1198 gchar *url = NULL;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1199 gchar *bg = NULL;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1200 gint len;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1201 gint tlen, smilelen, wpos=0;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1202 gint type;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1203 const gchar *c;
7280
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1204 gchar *amp;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1205
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1212 title = 0,
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1213 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1215 GSList *fonts = NULL;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1216 GtkIMHtmlScalable *scalable = NULL;
4612
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1217 GdkRectangle rect;
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1218 int y, height;
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1219
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1220
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 g_return_val_if_fail (text != NULL, NULL);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1224 printf("Appending: %s\n", text);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1225 c = text;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1226 len = strlen(text);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1227 ws = g_malloc(len + 1);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1228 ws[0] = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 if (options & GTK_IMHTML_RETURN_LOG)
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1231 str = g_string_new("");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1233 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &insert, ins);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1234
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1235 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1236 mark = gtk_text_buffer_create_mark (imhtml->text_buffer, NULL, &iter, /* right grav */ FALSE);
4612
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1237
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1238 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
4612
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1239 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1240
7794
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
1241 gtk_imhtml_clipboard_clear(NULL, imhtml);
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
1242 gtk_text_buffer_move_mark (imhtml->text_buffer,
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
1243 gtk_text_buffer_get_mark (imhtml->text_buffer, "insert"),
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
1244 &iter);
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
1245
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1246 if(((y + height) - (rect.y + rect.height)) > height
4612
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1247 && gtk_text_buffer_get_char_count(imhtml->text_buffer)){
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1248 options |= GTK_IMHTML_NO_SCROLL;
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1249 }
c05e6ecdc902 [gaim-migrate @ 4901]
Luke Schierer <lschiere@pidgin.im>
parents: 4477
diff changeset
1250
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1251 while (pos < len) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1252 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1253 c++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1254 pos++;
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1255 ws[wpos] = 0;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1256 switch (type)
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1257 {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1258 case 1: /* B */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1259 case 2: /* BOLD */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1260 case 54: /* STRONG */
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1261 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1262 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1263 else
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1264 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1265 if (bold == 0)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1266 gtk_imhtml_toggle_bold(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1267 bold++;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1268 ws[0] = '\0'; wpos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1269 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1270 case 3: /* /B */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1271 case 4: /* /BOLD */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1272 case 55: /* /STRONG */
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1273 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1274 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1275 else
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1276 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1277 ws[0] = '\0'; wpos = 0;
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1278
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1279 if (bold)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1280 bold--;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1281 if (bold == 0)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1282 gtk_imhtml_toggle_bold(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1283 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1284 case 5: /* I */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1285 case 6: /* ITALIC */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1286 case 52: /* EM */
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1287 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1288 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1289 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1290 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1291 ws[0] = '\0'; wpos = 0;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1292 if (italics == 0)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1293 gtk_imhtml_toggle_italic(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1294 italics++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1295 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1296 case 7: /* /I */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1297 case 8: /* /ITALIC */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1298 case 53: /* /EM */
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1299 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1300 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1301 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1302 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1303 ws[0] = '\0'; wpos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1304 if (italics)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1305 italics--;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1306 if (italics == 0)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1307 gtk_imhtml_toggle_italic(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1308 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1309 case 9: /* U */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1310 case 10: /* UNDERLINE */
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1311 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1312 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1313 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1314 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1315 ws[0] = '\0'; wpos = 0;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1316 if (underline == 0)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1317 gtk_imhtml_toggle_underline(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1318 underline++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1319 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1320 case 11: /* /U */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1321 case 12: /* /UNDERLINE */
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1322 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1323 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1324 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1325 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1326 ws[0] = '\0'; wpos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1327 if (underline)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1328 underline--;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1329 if (underline == 0)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1330 gtk_imhtml_toggle_underline(imhtml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1331 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1332 case 13: /* S */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1333 case 14: /* STRIKE */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1334 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1335 strike++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1336 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1337 case 15: /* /S */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1338 case 16: /* /STRIKE */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1339 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1340 if (strike)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1341 strike--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1342 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1343 case 17: /* SUB */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1344 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1345 sub++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1346 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1347 case 18: /* /SUB */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1348 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1349 if (sub)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1350 sub--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1351 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1352 case 19: /* SUP */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1353 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1354 sup++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1355 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1356 case 20: /* /SUP */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1357 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1358 if (sup)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1359 sup--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1360 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1361 case 21: /* PRE */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1362 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1363 pre++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1364 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1365 case 22: /* /PRE */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1366 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1367 if (pre)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1368 pre--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1369 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1370 case 23: /* TITLE */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1371 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1372 title++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1373 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1374 case 24: /* /TITLE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1375 if (title) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1376 if (options & GTK_IMHTML_NO_TITLE) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1377 wpos = 0;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1378 ws [wpos] = '\0';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1379 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1380 title--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1381 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1382 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1383 case 25: /* BR */
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5118
diff changeset
1384 case 58: /* BR/ */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1385 ws[wpos] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1386 wpos++;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1387 //NEW_BIT (NEW_TEXT_BIT);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1388 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1389 case 26: /* HR */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1390 case 42: /* HR (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1391 ws[wpos++] = '\n';
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1392 scalable = gtk_imhtml_hr_new();
7792
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
1393 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
1394 scalable->add_to(scalable, imhtml, &iter);
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
1395 scalable->scale(scalable, rect.width, rect.height);
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
1396 imhtml->scalables = g_list_append(imhtml->scalables, scalable);
4343
36cb0bb95b9c [gaim-migrate @ 4608]
Rob Flynn <gaim@robflynn.com>
parents: 4298
diff changeset
1397 ws[wpos++] = '\n';
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1398 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1399 case 27: /* /FONT */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1400 if (fonts) {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1401 GtkIMHtmlFontDetail *font = fonts->data;
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1402 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1403 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1404 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1405 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1406 ws[0] = '\0'; wpos = 0;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1407 //NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1408 fonts = g_slist_remove (fonts, font);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1409 if (font->face) {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1410 gtk_imhtml_toggle_fontface(imhtml, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1411 g_free (font->face);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1412 }
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1413 if (font->fore) {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1414 gtk_imhtml_toggle_forecolor(imhtml, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1415 g_free (font->fore);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1416 }
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1417 if (font->back) {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1418 gtk_imhtml_toggle_backcolor(imhtml, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1419 g_free (font->back);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1420 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1421 if (font->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1422 g_free (font->sml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1423 g_free (font);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1424 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1425 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1426 case 28: /* /A */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1427 if (url) {
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1428 //NEW_BIT(NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1429 g_free(url);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1430 url = NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1431 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1432 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1433 case 29: /* P */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1434 case 30: /* /P */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1435 case 31: /* H3 */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1436 case 32: /* /H3 */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1437 case 33: /* HTML */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1438 case 34: /* /HTML */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1439 case 35: /* BODY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1440 case 36: /* /BODY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1441 case 37: /* FONT */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1442 case 38: /* HEAD */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1443 case 39: /* /HEAD */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1444 case 40: /* BINARY */
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1445 case 41: /* /BINARY */
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1446 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1447 case 43: /* FONT (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1448 {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1449 gchar *color, *back, *face, *size, *sml;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1450 GtkIMHtmlFontDetail *font, *oldfont = NULL;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1451 color = gtk_imhtml_get_html_opt (tag, "COLOR=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1452 back = gtk_imhtml_get_html_opt (tag, "BACK=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1453 face = gtk_imhtml_get_html_opt (tag, "FACE=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1454 size = gtk_imhtml_get_html_opt (tag, "SIZE=");
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1455 sml = gtk_imhtml_get_html_opt (tag, "SML=");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1456 if (!(color || back || face || size || sml))
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1457 break;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1458
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1459 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1460 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1461 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1462 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1463 ws[0] = '\0'; wpos = 0;
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1464
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1465 font = g_new0 (GtkIMHtmlFontDetail, 1);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1466 if (fonts)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1467 oldfont = fonts->data;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1468
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1469 if (color && !(options & GTK_IMHTML_NO_COLOURS))
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1470 font->fore = color;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1471 else if (oldfont && oldfont->fore)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1472 font->fore = g_strdup(oldfont->fore);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1473 if (font->fore)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1474 gtk_imhtml_toggle_forecolor(imhtml, font->fore);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1475
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1476 if (back && !(options & GTK_IMHTML_NO_COLOURS))
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1477 font->back = back;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1478 else if (oldfont && oldfont->back)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1479 font->back = g_strdup(oldfont->back);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1480 if (font->back)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1481 gtk_imhtml_toggle_backcolor(imhtml, font->back);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1482
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1483 if (face && !(options & GTK_IMHTML_NO_FONTS))
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1484 font->face = face;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1485 else if (oldfont && oldfont->face)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1486 font->face = g_strdup(oldfont->face);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1487 if (font->face)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1488 gtk_imhtml_toggle_fontface(imhtml, font->face);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1489
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1490 if (sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1491 font->sml = sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1492 else if (oldfont && oldfont->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1493 font->sml = g_strdup(oldfont->sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1494
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1495 if (size && !(options & GTK_IMHTML_NO_SIZES)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1496 if (*size == '+') {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1497 sscanf (size + 1, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1498 font->size += 3;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1499 } else if (*size == '-') {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1500 sscanf (size + 1, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1501 font->size = MAX (0, 3 - font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1502 } else if (isdigit (*size)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1503 sscanf (size, "%hd", &font->size);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1504 }
6042
460b4ba2d452 [gaim-migrate @ 6492]
Mark Doliner <mark@kingant.net>
parents: 5967
diff changeset
1505 if (font->size > 100)
460b4ba2d452 [gaim-migrate @ 6492]
Mark Doliner <mark@kingant.net>
parents: 5967
diff changeset
1506 font->size = 100;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1507 } else if (oldfont)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1508 font->size = oldfont->size;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1509 // gtk_imhtml_font_set_size(imhtml, font->size);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1510 g_free(size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1511 fonts = g_slist_prepend (fonts, font);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1512 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1513 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1514 case 44: /* BODY (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1515 if (!(options & GTK_IMHTML_NO_COLOURS)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1516 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1517 if (bgcolor) {
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1518 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1519 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1520 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1521 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1522 ws[0] = '\0'; wpos = 0;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1523 // NEW_BIT(NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1524 if (bg)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1525 g_free(bg);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1526 bg = bgcolor;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1527 gtk_imhtml_toggle_backcolor(imhtml, bg);
2885
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
1528 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1530 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1531 case 45: /* A (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1532 {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1533 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1534 if (href) {
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1535 // NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1536 if (url)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1537 g_free (url);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1538 url = href;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1539 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1540 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1541 break;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1542 case 46: /* IMG (opt) */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1543 case 59: /* IMG */
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1544 {
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1545 GdkPixbuf *img = NULL;
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1546 const gchar *filename = NULL;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1547
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1548 if (images && images->data) {
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1549 img = images->data;
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1550 images = images->next;
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1551 filename = g_object_get_data(G_OBJECT(img), "filename");
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1552 g_object_ref(G_OBJECT(img));
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1553 } else {
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1554 img = gtk_widget_render_icon(GTK_WIDGET(imhtml),
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1555 GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON,
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1556 "gtkimhtml-missing-image");
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1557 }
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1558
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1559 scalable = gtk_imhtml_image_new(img, filename);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1560 //NEW_BIT(NEW_SCALABLE_BIT);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1561 g_object_unref(G_OBJECT(img));
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1562 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1563 case 47: /* P (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1564 case 48: /* H3 (opt) */
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5091
diff changeset
1565 case 49: /* HTML (opt) */
5101
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1566 case 50: /* CITE */
a7e9036cd46f [gaim-migrate @ 5464]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
1567 case 51: /* /CITE */
5104
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1568 case 56: /* SPAN */
a20a644e0da4 [gaim-migrate @ 5467]
Nathan Walp <nwalp@pidgin.im>
parents: 5101
diff changeset
1569 case 57: /* /SPAN */
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1570 break;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1571 case 60: /* comment */
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1572 //NEW_BIT (NEW_TEXT_BIT);
6124
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
1573 if (imhtml->show_comments)
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
1574 wpos = g_snprintf (ws, len, "%s", tag);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1575 // NEW_BIT (NEW_COMMENT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1576 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1577 default:
6882
4f8258b2bb8d [gaim-migrate @ 7428]
Luke Schierer <lschiere@pidgin.im>
parents: 6839
diff changeset
1578 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1579 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1580 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1581 pos += tlen;
4138
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
1582 if(tag)
6b2d0ce7fb18 [gaim-migrate @ 4356]
Luke Schierer <lschiere@pidgin.im>
parents: 4046
diff changeset
1583 g_free(tag); /* This was allocated back in VALID_TAG() */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1584 } 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
1585 while(*amp) {
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1586 ws [wpos++] = *amp++;
f946af3b0039 [gaim-migrate @ 7859]
Nathan Walp <nwalp@pidgin.im>
parents: 7140
diff changeset
1587 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1588 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1589 pos += tlen;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1590 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1591 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1592 ws[wpos] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1593 wpos++;
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1594 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1595 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1596 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1597 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1598 ws[0] = '\0';
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1599 wpos = 0;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1600 //NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602 c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1603 pos++;
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1604 } else if (imhtml->show_smileys && (gtk_imhtml_is_smiley (imhtml, fonts, c, &smilelen) || gtk_imhtml_is_smiley(imhtml, NULL, c, &smilelen))) {
6814
782907a6ae65 [gaim-migrate @ 7354]
Christian Hammond <chipx86@chipx86.com>
parents: 6648
diff changeset
1605 GtkTextChildAnchor *anchor;
6882
4f8258b2bb8d [gaim-migrate @ 7428]
Luke Schierer <lschiere@pidgin.im>
parents: 6839
diff changeset
1606 GtkWidget *icon = NULL;
7344
7ba7fedc1d8b [gaim-migrate @ 7935]
Sean Egan <seanegan@gmail.com>
parents: 7295
diff changeset
1607 GtkTextIter copy;
6882
4f8258b2bb8d [gaim-migrate @ 7428]
Luke Schierer <lschiere@pidgin.im>
parents: 6839
diff changeset
1608 GdkPixbufAnimation *annipixbuf = NULL;
4f8258b2bb8d [gaim-migrate @ 7428]
Luke Schierer <lschiere@pidgin.im>
parents: 6839
diff changeset
1609 GdkPixbuf *pixbuf = NULL;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1610 GtkIMHtmlFontDetail *fd;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1611
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1612 gchar *sml = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1613 if (fonts) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1614 fd = fonts->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1615 sml = fd->sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1616 }
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1617 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1618 gtk_imhtml_insert_link(imhtml, url, ws);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1619 else {
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1620 printf("Inserting %s\n", ws);
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1621 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1622 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1623 wpos = g_snprintf (ws, smilelen + 1, "%s", c);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1624 gtk_imhtml_insert_smiley(imhtml, sml, ws);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1625
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1626 ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1627 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1628
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1629 c += smilelen;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1630 pos += smilelen;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1631 wpos = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1632 ws[0] = 0;
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
1633 } else if (*c) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1634 ws [wpos++] = *c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1635 pos++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1636 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1637 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1638 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1639 }
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1640 if (url)
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1641 gtk_imhtml_insert_link(imhtml, url, ws);
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1642 else
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
1643 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1644 ws[0] = '\0'; wpos = 0;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1645
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1646 //NEW_BIT(NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1647 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1648 g_free (url);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1649 if (str)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1650 str = g_string_append (str, "</A>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1651 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1652
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1653 while (fonts) {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1654 GtkIMHtmlFontDetail *font = fonts->data;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1655 fonts = g_slist_remove (fonts, font);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1656 if (font->face)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1657 g_free (font->face);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1658 if (font->fore)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1659 g_free (font->fore);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1660 if (font->back)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1661 g_free (font->back);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1662 if (font->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1663 g_free (font->sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1664 g_free (font);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1665 if (str)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1666 str = g_string_append (str, "</FONT>");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1667 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1668
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1669 if (str) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1670 while (bold) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1671 str = g_string_append (str, "</B>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1672 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1673 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674 while (italics) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1675 str = g_string_append (str, "</I>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1676 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1677 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1678 while (underline) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1679 str = g_string_append (str, "</U>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1680 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1681 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1682 while (strike) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1683 str = g_string_append (str, "</S>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1684 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1685 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1686 while (sub) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1687 str = g_string_append (str, "</SUB>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690 while (sup) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1691 str = g_string_append (str, "</SUP>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694 while (title) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1695 str = g_string_append (str, "</TITLE>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1698 while (pre) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1699 str = g_string_append (str, "</PRE>");
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1700 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1701 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1703 g_free (ws);
4630
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4629
diff changeset
1704 if(bg)
5cdfd20daa07 [gaim-migrate @ 4921]
Sean Egan <seanegan@gmail.com>
parents: 4629
diff changeset
1705 g_free(bg);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1706 gtk_imhtml_close_tags(imhtml);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1707 if (!(options & GTK_IMHTML_NO_SCROLL))
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1708 gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (imhtml), mark,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
1709 0, TRUE, 0.0, 1.0);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1710 gtk_text_buffer_delete_mark (imhtml->text_buffer, mark);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1711 gtk_text_buffer_move_mark (imhtml->text_buffer,
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1712 gtk_text_buffer_get_mark (imhtml->text_buffer, "insert"),
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
1713 &iter);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1714 return str;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1715 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1716
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
1717 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml)
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
1718 {
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
1719 g_hash_table_destroy(imhtml->smiley_data);
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
1720 gtk_smiley_tree_destroy(imhtml->default_smilies);
4892
dc6de8ad81ae [gaim-migrate @ 5222]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
1721 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
1722 g_free, (GDestroyNotify)gtk_smiley_tree_destroy);
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
1723 imhtml->default_smilies = gtk_smiley_tree_new();
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4264
diff changeset
1724 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1725 void gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1726 gboolean show)
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1727 {
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1728 imhtml->show_smileys = show;
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1729 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1730
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1731 void gtk_imhtml_show_comments (GtkIMHtml *imhtml,
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1732 gboolean show)
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1733 {
6124
16fd7811effd [gaim-migrate @ 6598]
Mark Doliner <mark@kingant.net>
parents: 6066
diff changeset
1734 imhtml->show_comments = show;
4253
6c8ea04270e1 [gaim-migrate @ 4504]
Sean Egan <seanegan@gmail.com>
parents: 4201
diff changeset
1735 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1736
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1737 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1738 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1739 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1740 GtkTextIter start, end;
7700
8a40952f5f67 [gaim-migrate @ 8345]
Sean Egan <seanegan@gmail.com>
parents: 7697
diff changeset
1741 GList *del = imhtml->format_spans;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1742
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1743 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1744 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1745 gtk_text_buffer_delete(imhtml->text_buffer, &start, &end);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1746
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1747 while (imhtml->format_spans) {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1748 GtkIMHtmlFormatSpan *span = imhtml->format_spans->data;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1749 if (span->start_tag)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1750 g_free(span->start_tag);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1751 if (span->end_tag)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1752 g_free(span->end_tag);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1753 g_free(span);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1754 imhtml->format_spans = imhtml->format_spans->next;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1755 }
7700
8a40952f5f67 [gaim-migrate @ 8345]
Sean Egan <seanegan@gmail.com>
parents: 7697
diff changeset
1756 g_list_free(del);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1757 imhtml->edit.bold = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1758 imhtml->edit.italic = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
1759 imhtml->edit.underline = NULL;
7717
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
1760 imhtml->edit.fontface = NULL;
7728
043fa48f2cc2 [gaim-migrate @ 8373]
Sean Egan <seanegan@gmail.com>
parents: 7717
diff changeset
1761 imhtml->edit.forecolor = NULL;
043fa48f2cc2 [gaim-migrate @ 8373]
Sean Egan <seanegan@gmail.com>
parents: 7717
diff changeset
1762 imhtml->edit.backcolor = NULL;
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
1763 imhtml->edit.sizespan = NULL;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
1764 imhtml->edit.fontsize = 3;
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1765 }
2363
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
1766
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1767 void gtk_imhtml_page_up (GtkIMHtml *imhtml)
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1768 {
5282
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1769 GdkRectangle rect;
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1770 GtkTextIter iter;
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1771
5282
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1772 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1773 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
1774 rect.y - rect.height);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1775 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1776
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1777 }
5282
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1778 void gtk_imhtml_page_down (GtkIMHtml *imhtml)
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1779 {
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1780 GdkRectangle rect;
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1781 GtkTextIter iter;
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1782
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1783 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1784 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
1785 rect.y + rect.height);
2d7f9a092b81 [gaim-migrate @ 5654]
Luke Schierer <lschiere@pidgin.im>
parents: 5177
diff changeset
1786 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
1787 }
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1788
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1789 /* GtkIMHtmlScalable, gtk_imhtml_image, gtk_imhtml_hr */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1790 GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename)
4735
66c2388046fb [gaim-migrate @ 5050]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1791 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1792 GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage));
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1793 GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixbuf(img));
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1794
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1795 GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1796 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
1797 GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free;
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
1798
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
1799 im_image->pixbuf = img;
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1800 im_image->image = image;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1801 im_image->width = gdk_pixbuf_get_width(img);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1802 im_image->height = gdk_pixbuf_get_height(img);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1803 im_image->mark = NULL;
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1804 im_image->filename = filename ? g_strdup(filename) : NULL;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1805
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
1806 g_object_ref(img);
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1807 return GTK_IMHTML_SCALABLE(im_image);
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1808 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1809
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1810 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
1811 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1812 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1813
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1814 if(image->width > width || image->height > height){
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1815 GdkPixbuf *new_image = NULL;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1816 float factor;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1817 int new_width = image->width, new_height = image->height;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1818
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1819 if(image->width > width){
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1820 factor = (float)(width)/image->width;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1821 new_width = width;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1822 new_height = image->height * factor;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1823 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1824 if(new_height > height){
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1825 factor = (float)(height)/new_height;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1826 new_height = height;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1827 new_width = new_width * factor;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1828 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1829
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
1830 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
1831 gtk_image_set_from_pixbuf(image->image, new_image);
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1832 g_object_unref(G_OBJECT(new_image));
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1833 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1834 }
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4892
diff changeset
1835
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1836 static void write_img_to_file(GtkWidget *w, GtkFileSelection *sel)
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1837 {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1838 const gchar *filename = gtk_file_selection_get_filename(sel);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1839 gchar *dirname;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1840 GtkIMHtmlImage *image = g_object_get_data(G_OBJECT(sel), "GtkIMHtmlImage");
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1841 gchar *type = NULL;
5019
eb1d45bffe66 [gaim-migrate @ 5355]
Luke Schierer <lschiere@pidgin.im>
parents: 5015
diff changeset
1842 GError *error = NULL;
5015
a17a84895585 [gaim-migrate @ 5351]
Nathan Walp <nwalp@pidgin.im>
parents: 5012
diff changeset
1843 #if GTK_CHECK_VERSION(2,2,0)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1844 GSList *formats = gdk_pixbuf_get_formats();
6162
7e967f2d6721 [gaim-migrate @ 6642]
Mark Doliner <mark@kingant.net>
parents: 6124
diff changeset
1845 #else
7e967f2d6721 [gaim-migrate @ 6642]
Mark Doliner <mark@kingant.net>
parents: 6124
diff changeset
1846 char *basename = g_path_get_basename(filename);
7e967f2d6721 [gaim-migrate @ 6642]
Mark Doliner <mark@kingant.net>
parents: 6124
diff changeset
1847 char *ext = strrchr(basename, '.');
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
1848 #endif
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1849
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1850 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1851 /* append a / if needed */
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1852 if (filename[strlen(filename) - 1] != '/') {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1853 dirname = g_strconcat(filename, "/", NULL);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1854 } else {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1855 dirname = g_strdup(filename);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1856 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1857 gtk_file_selection_set_filename(sel, dirname);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1858 g_free(dirname);
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
1859 return;
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1860 }
5959
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
1861
0a2a32b1917c [gaim-migrate @ 6405]
Mark Doliner <mark@kingant.net>
parents: 5582
diff changeset
1862 #if GTK_CHECK_VERSION(2,2,0)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1863 while(formats){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1864 GdkPixbufFormat *format = formats->data;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1865 gchar **extensions = gdk_pixbuf_format_get_extensions(format);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1866 gpointer p = extensions;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1867
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1868 while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1869 gchar *fmt_ext = extensions[0];
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1870 const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1871
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1872 if(!strcmp(fmt_ext, file_ext)){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1873 type = gdk_pixbuf_format_get_name(format);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1874 break;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1875 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1876
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1877 extensions++;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1878 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1879
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1880 g_strfreev(p);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1881
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1882 if(type)
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1883 break;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1884
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1885 formats = formats->next;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1886 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1887
5020
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1888 g_slist_free(formats);
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1889 #else
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1890 /* this is really ugly code, but I think it will work */
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1891 if(ext) {
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1892 ext++;
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1893 if(!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg"))
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1894 type = g_strdup("jpeg");
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1895 else if(!g_ascii_strcasecmp(ext, "png"))
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1896 type = g_strdup("png");
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1897 }
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1898
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1899 g_free(basename);
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1900 #endif
29c87c6e75d9 [gaim-migrate @ 5356]
Nathan Walp <nwalp@pidgin.im>
parents: 5019
diff changeset
1901
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1902 /* 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
1903 it's a png */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1904 if(!type){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1905 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
1906 _("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
1907 type = g_strdup("png");
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1908 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1909
5046
44945824ba60 [gaim-migrate @ 5394]
Nathan Walp <nwalp@pidgin.im>
parents: 5020
diff changeset
1910 gdk_pixbuf_save(image->pixbuf, filename, type, &error, NULL);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1911
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1912 if(error){
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1913 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
1914 _("Error saving image: %s"), error->message);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1915 g_error_free(error);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1916 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1917
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1918 g_free(type);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1919 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1920
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1921 static void gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImage *image)
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1922 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1923 GtkWidget *sel = gtk_file_selection_new(_("Save Image"));
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1924
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1925 if (image->filename)
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1926 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
1927 g_object_set_data(G_OBJECT(sel), "GtkIMHtmlImage", image);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1928 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
1929 G_CALLBACK(write_img_to_file), sel);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1930
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1931 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
1932 G_CALLBACK(gtk_widget_destroy), sel);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1933 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(sel)->cancel_button), "clicked",
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
1934 G_CALLBACK(gtk_widget_destroy), sel);
5012
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1935
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1936 gtk_widget_show(sel);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1937 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1938
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1939 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
1940 {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1941 GdkEventButton *event_button = (GdkEventButton *) event;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1942
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1943 if (event->type == GDK_BUTTON_RELEASE) {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1944 if(event_button->button == 3) {
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1945 GtkWidget *img, *item, *menu;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1946 gchar *text = g_strdup_printf(_("_Save Image..."));
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1947 menu = gtk_menu_new();
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1948
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1949 /* buttons and such */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1950 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
1951 item = gtk_image_menu_item_new_with_mnemonic(text);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1952 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
1953 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
1954 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1955
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1956 gtk_widget_show_all(menu);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1957 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1958 event_button->button, event_button->time);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1959
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1960 g_free(text);
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1961 return TRUE;
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1962 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1963 }
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1964 if(event->type == GDK_BUTTON_PRESS && event_button->button == 3)
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1965 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
1966 be caught by the regular GtkTextView menu */
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1967 else
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1968 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
1969
3ee1b1409660 [gaim-migrate @ 5348]
Nathan Walp <nwalp@pidgin.im>
parents: 4997
diff changeset
1970 }
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1971 void gtk_imhtml_image_free(GtkIMHtmlScalable *scale)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1972 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1973 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1974
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1975 g_object_unref(image->pixbuf);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1976 if (image->filename)
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6882
diff changeset
1977 g_free(image->filename);
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1978 g_free(scale);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1979 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1980
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1981 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
1982 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1983 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1984 GtkWidget *box = gtk_event_box_new();
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1985 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
1986
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1987 gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1988
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1989 gtk_widget_show(GTK_WIDGET(image->image));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1990 gtk_widget_show(box);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1991
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1992 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
1993 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
1994 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1995
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1996 GtkIMHtmlScalable *gtk_imhtml_hr_new()
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1997 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1998 GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr));
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
1999
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2000 GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2001 GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2002 GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2003
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2004 hr->sep = gtk_hseparator_new();
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2005 gtk_widget_set_size_request(hr->sep, 5000, 2);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2006 gtk_widget_show(hr->sep);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2007
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2008 return GTK_IMHTML_SCALABLE(hr);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2009 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2010
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2011 void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2012 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2013 gtk_widget_set_size_request(((GtkIMHtmlHr *)scale)->sep, width, 2);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2014 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2015
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2016 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
2017 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2018 GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale;
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2019 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter);
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
2020 g_object_set_data(G_OBJECT(anchor), "text_tag", "<hr>");
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2021 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
2022 }
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2023
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2024 void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale)
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2025 {
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2026 g_free(scale);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
2027 }
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2028
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2029 gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text)
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2030 {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2031 GtkTextIter iter, start, end;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2032 gboolean new_search = TRUE;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2033
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2034 g_return_val_if_fail(imhtml != NULL, FALSE);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2035 g_return_val_if_fail(text != NULL, FALSE);
7754
f75991b27e94 [gaim-migrate @ 8399]
Mark Doliner <mark@kingant.net>
parents: 7750
diff changeset
2036
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2037 if (imhtml->search_string && !strcmp(text, imhtml->search_string))
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2038 new_search = FALSE;
7754
f75991b27e94 [gaim-migrate @ 8399]
Mark Doliner <mark@kingant.net>
parents: 7750
diff changeset
2039
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2040 if (new_search) {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2041 gtk_imhtml_search_clear(imhtml);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2042 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2043 } else {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2044 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter,
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2045 gtk_text_buffer_get_mark(imhtml->text_buffer, "search"));
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2046 }
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2047 imhtml->search_string = g_strdup(text);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2048
7358
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
2049 if (gtk_source_iter_forward_search(&iter, imhtml->search_string,
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
2050 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2051 &start, &end, NULL)) {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2052
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2053 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
2054 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &end, FALSE);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2055 if (new_search) {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2056 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2057 do
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2058 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2059 while (gtk_source_iter_forward_search(&end, imhtml->search_string,
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2060 GTK_SOURCE_SEARCH_VISIBLE_ONLY |
7358
78c1fc730dc4 [gaim-migrate @ 7951]
Sean Egan <seanegan@gmail.com>
parents: 7354
diff changeset
2061 GTK_SOURCE_SEARCH_CASE_INSENSITIVE,
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2062 &start, &end, NULL));
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2063 }
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2064 return TRUE;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2065 }
7754
f75991b27e94 [gaim-migrate @ 8399]
Mark Doliner <mark@kingant.net>
parents: 7750
diff changeset
2066
f75991b27e94 [gaim-migrate @ 8399]
Mark Doliner <mark@kingant.net>
parents: 7750
diff changeset
2067 gtk_imhtml_search_clear(imhtml);
f75991b27e94 [gaim-migrate @ 8399]
Mark Doliner <mark@kingant.net>
parents: 7750
diff changeset
2068
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2069 return FALSE;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2070 }
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2071
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2072 void gtk_imhtml_search_clear(GtkIMHtml *imhtml)
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2073 {
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2074 GtkTextIter start, end;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2075
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2076 g_return_if_fail(imhtml != NULL);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2077
7295
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2078 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2079 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2080
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2081 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
2082 if (imhtml->search_string)
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2083 g_free(imhtml->search_string);
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2084 imhtml->search_string = NULL;
c7f0a4397d9e [gaim-migrate @ 7879]
Sean Egan <seanegan@gmail.com>
parents: 7287
diff changeset
2085 }
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2086
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2087 /* Editable stuff */
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2088 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2089 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2090 GtkIMHtmlFormatSpan *span = NULL;
7734
e11cef6aabba [gaim-migrate @ 8379]
Sean Egan <seanegan@gmail.com>
parents: 7732
diff changeset
2091 GtkTextIter end;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2092
7717
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2093 gtk_text_iter_forward_chars(iter, len);
7734
e11cef6aabba [gaim-migrate @ 8379]
Sean Egan <seanegan@gmail.com>
parents: 7732
diff changeset
2094 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
e11cef6aabba [gaim-migrate @ 8379]
Sean Egan <seanegan@gmail.com>
parents: 7732
diff changeset
2095 gtk_text_iter_forward_char(&end);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2096
7794
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
2097 if (!gtk_text_iter_equal(&end, iter))
d2710acd0020 [gaim-migrate @ 8440]
Sean Egan <seanegan@gmail.com>
parents: 7792
diff changeset
2098 return;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2099
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2100
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2101 if ((span = imhtml->edit.bold)) {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2102 GtkTextIter bold;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2103 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &bold, span->start);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2104 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &bold, iter);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2105 }
7729
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2106
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2107 if ((span = imhtml->edit.italic)) {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2108 GtkTextIter italic;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2109 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &italic, span->start);
7729
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2110 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &italic,
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2111 iter);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2112 }
7729
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2113
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2114 if ((span = imhtml->edit.underline)) {
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2115 GtkTextIter underline;
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2116 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &underline, span->start);
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2117 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &underline,
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2118 iter);
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2119 }
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2120
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2121 if ((span = imhtml->edit.forecolor)) {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2122 GtkTextIter fore;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2123 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &fore, span->start);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2124 gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &fore, iter);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2125 }
7729
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2126
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2127 if ((span = imhtml->edit.backcolor)) {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2128 GtkTextIter back;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2129 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &back, span->start);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2130 gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &back, iter);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2131 }
7729
2ffb337be055 [gaim-migrate @ 8374]
Nathan Walp <nwalp@pidgin.im>
parents: 7728
diff changeset
2132
7717
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2133 if ((span = imhtml->edit.fontface)) {
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2134 GtkTextIter face;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2135 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &face, span->start);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2136 gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &face, iter);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2137 }
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2138
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2139 if ((span = imhtml->edit.sizespan)) {
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2140 GtkTextIter size;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2141 /* We create the tags here so that one can grow font or shrink font several times
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2142 * in a row without creating unnecessary tags */
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2143 if (span->tag == NULL) {
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2144 span->tag = gtk_text_buffer_create_tag
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2145 (imhtml->text_buffer, NULL, "size-points", (double)_point_sizes [imhtml->edit.fontsize-1], NULL);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2146 span->start_tag = g_strdup_printf("<font size=\"%d\">", imhtml->edit.fontsize);
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2147 span->end_tag = g_strdup("</font>");
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2148 }
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2149 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &size, span->start);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2150 gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &size, iter);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2151 }
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2152 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2153
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2154 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable)
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2155 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2156 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2157 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2158 imhtml->editable = editable;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2159 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2160
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2161 gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml)
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2162 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2163 return imhtml->editable;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2164 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2165
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2166 gboolean gtk_imhtml_toggle_bold(GtkIMHtml *imhtml)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2167 {
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2168 GtkIMHtmlFormatSpan *span;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2169 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2170 GtkTextIter iter;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2171 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2172 if (!imhtml->edit.bold) {
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2173 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2174 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2175 span->start_tag = g_strdup("<b>");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2176 span->end = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2177 span->end_tag = g_strdup("</b>");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2178 span->buffer = imhtml->text_buffer;
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2179 span->tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "BOLD");
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2180 imhtml->edit.bold = span;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2181 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2182 } else {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2183 span = imhtml->edit.bold;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2184 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2185 imhtml->edit.bold = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2186 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2187 return imhtml->edit.bold != NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2188 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2189
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2190 gboolean gtk_imhtml_toggle_italic(GtkIMHtml *imhtml)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2191 {
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2192 GtkIMHtmlFormatSpan *span;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2193 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2194 GtkTextIter iter;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2195 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2196 if (!imhtml->edit.italic) {
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2197 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2198 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2199 span->start_tag = g_strdup("<i>");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2200 span->end = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2201 span->end_tag = g_strdup("</i>");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2202 span->buffer = imhtml->text_buffer;
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2203 span->tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "ITALIC");
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2204 imhtml->edit.italic = span;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2205 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2206 } else {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2207 span = imhtml->edit.italic;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2208 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2209 imhtml->edit.italic = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2210 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2211 return imhtml->edit.italic != NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2212 }
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2213
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2214 gboolean gtk_imhtml_toggle_underline(GtkIMHtml *imhtml)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2215 {
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2216 GtkIMHtmlFormatSpan *span;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2217 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2218 GtkTextIter iter;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2219 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2220 if (!imhtml->edit.underline) {
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2221 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2222 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2223 span->start_tag = g_strdup("<u>");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2224 span->end = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2225 span->end_tag = g_strdup("</u>");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2226 span->buffer = imhtml->text_buffer;
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2227 span->tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "UNDERLINE");
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2228 imhtml->edit.underline = span;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2229 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2230 } else {
7697
e544e234ecbb [gaim-migrate @ 8342]
Sean Egan <seanegan@gmail.com>
parents: 7694
diff changeset
2231 span = imhtml->edit.underline;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2232 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2233 imhtml->edit.underline = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2234 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2235 return imhtml->edit.underline != NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2236 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2237
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2238 void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2239 {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2240 GtkIMHtmlFormatSpan *span;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2241 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2242 GtkTextIter iter;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2243 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2244
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2245 imhtml->edit.fontsize = size;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2246
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2247 if (imhtml->edit.sizespan) {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2248 GtkTextIter iter2;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2249 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter2, imhtml->edit.sizespan->start);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2250 if (gtk_text_iter_equal(&iter2, &iter))
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2251 return;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2252 span = imhtml->edit.sizespan;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2253 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2254 }
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2255 if (size != -1) {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2256 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2257 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2258 span->end = NULL;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2259 span->buffer = imhtml->text_buffer;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2260 span->tag = NULL;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2261 imhtml->edit.sizespan = span;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2262 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2263 }
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2264 }
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2265
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2266 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml)
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2267 {
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2268 GtkIMHtmlFormatSpan *span;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2269 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2270 GtkTextIter iter;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2271 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2272 if (imhtml->edit.fontsize == 1)
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2273 return;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2274
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2275 imhtml->edit.fontsize--;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2276
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2277 if (imhtml->edit.sizespan) {
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2278 GtkTextIter iter2;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2279 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter2, imhtml->edit.sizespan->start);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2280 if (gtk_text_iter_equal(&iter2, &iter))
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2281 return;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2282 span = imhtml->edit.sizespan;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2283 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2284 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2285
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2286 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2287 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2288 span->end = NULL;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2289 span->buffer = imhtml->text_buffer;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2290 span->tag = NULL;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2291 imhtml->edit.sizespan = span;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2292 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2293 }
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2294
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2295 void gtk_imhtml_font_grow(GtkIMHtml *imhtml)
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2296 {
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2297 GtkIMHtmlFormatSpan *span;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2298 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2299 GtkTextIter iter;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2300 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2301 if (imhtml->edit.fontsize == MAX_FONT_SIZE)
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2302 return;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2303
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2304 imhtml->edit.fontsize++;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2305
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2306 if (imhtml->edit.sizespan) {
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2307 GtkTextIter iter2;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2308 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter2, imhtml->edit.sizespan->start);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2309 if (gtk_text_iter_equal(&iter2, &iter))
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2310 return;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2311 span = imhtml->edit.sizespan;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2312 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2313 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2314
7740
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2315 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2316 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2317 span->end = NULL;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2318 span->tag = NULL;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2319 span->buffer = imhtml->text_buffer;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2320 imhtml->edit.sizespan = span;
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2321 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2322 }
ddc450689c05 [gaim-migrate @ 8385]
Sean Egan <seanegan@gmail.com>
parents: 7736
diff changeset
2323
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2324 gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color)
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2325 {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2326 GtkIMHtmlFormatSpan *span;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2327 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2328 GtkTextIter iter;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2329 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2330 if (!imhtml->edit.forecolor) {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2331 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2332 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2333 span->start_tag = g_strdup_printf("<font color=\"%s\">", color);
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2334 span->end = NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2335 span->end_tag = g_strdup("</font>");
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2336 span->buffer = imhtml->text_buffer;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2337 span->tag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", color, NULL);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2338 imhtml->edit.forecolor = span;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2339 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2340 } else {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2341 span = imhtml->edit.forecolor;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2342 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2343 imhtml->edit.forecolor = NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2344 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2345
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2346
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2347 return imhtml->edit.forecolor != NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2348 }
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2349
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2350 gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color)
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2351 {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2352 GtkIMHtmlFormatSpan *span;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2353 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2354 GtkTextIter iter;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2355 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2356 if (!imhtml->edit.backcolor) {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2357 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2358 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2359 span->start_tag = g_strdup_printf("<font back=\"%s\">", color);
7714
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2360 span->end = NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2361 span->end_tag = g_strdup("</font>");
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2362 span->buffer = imhtml->text_buffer;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2363 span->tag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "background", color, NULL);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2364 imhtml->edit.backcolor = span;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2365 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2366 } else {
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2367 span = imhtml->edit.backcolor;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2368 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2369 imhtml->edit.backcolor = NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2370 }
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2371 return imhtml->edit.backcolor != NULL;
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2372 }
3d9d3d21e600 [gaim-migrate @ 8359]
Sean Egan <seanegan@gmail.com>
parents: 7709
diff changeset
2373
7717
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2374 gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face)
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2375 {
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2376 GtkIMHtmlFormatSpan *span;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2377 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2378 GtkTextIter iter;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2379 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2380 if (!imhtml->edit.fontface) {
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2381 span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2382 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2383 span->start_tag = g_strdup_printf("<font face=\"%s\">", face);
7717
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2384 span->end = NULL;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2385 span->end_tag = g_strdup("</font>");
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2386 span->buffer = imhtml->text_buffer;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2387 span->tag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "family", face, NULL);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2388 imhtml->edit.fontface = span;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2389 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2390 } else {
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2391 span = imhtml->edit.fontface;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2392 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2393 imhtml->edit.fontface = NULL;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2394 }
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2395 return imhtml->edit.fontface != NULL;
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2396 }
db3bdae1761e [gaim-migrate @ 8362]
Sean Egan <seanegan@gmail.com>
parents: 7716
diff changeset
2397
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2398 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, const char *url, const char *text)
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2399 {
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2400 GtkIMHtmlFormatSpan *span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2401 GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2402 GtkTextIter iter;
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2403 GtkTextTag *tag, *linktag;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2404
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2405 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, NULL);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2406 g_object_set_data(G_OBJECT(tag), "link_url", g_strdup(url));
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2407
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2408 linktag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "LINK");
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2409
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2410 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2411 span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2412 span->buffer = imhtml->text_buffer;
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
2413 span->start_tag = g_strdup_printf("<a href=\"%s\">", url);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2414 span->end_tag = g_strdup("</a>");
7800
1eb2c09b9a86 [gaim-migrate @ 8446]
Sean Egan <seanegan@gmail.com>
parents: 7794
diff changeset
2415 g_signal_connect(G_OBJECT(tag), "event", G_CALLBACK(tag_event), g_strdup(url));
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2416
7707
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2417 gtk_text_buffer_insert_with_tags(imhtml->text_buffer, &iter, text, strlen(text), linktag, tag, NULL);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2418 span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2419 imhtml->format_spans = g_list_append(imhtml->format_spans, span);
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2420 }
17756d5dcfdf [gaim-migrate @ 8352]
Sean Egan <seanegan@gmail.com>
parents: 7700
diff changeset
2421
7736
662a33ce4343 [gaim-migrate @ 8381]
Sean Egan <seanegan@gmail.com>
parents: 7735
diff changeset
2422 void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley)
7735
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2423 {
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2424 GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2425 GtkTextIter iter;
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2426 GdkPixbuf *pixbuf = NULL;
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2427 GdkPixbufAnimation *annipixbuf = NULL;
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2428 GtkWidget *icon = NULL;
7792
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
2429 printf("%s %s\n", sml, smiley);
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
2430 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2431 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, &iter);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
2432 g_object_set_data(G_OBJECT(anchor), "text_tag", g_strdup(smiley));
7735
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2433
7736
662a33ce4343 [gaim-migrate @ 8381]
Sean Egan <seanegan@gmail.com>
parents: 7735
diff changeset
2434 annipixbuf = gtk_smiley_tree_image(imhtml, sml, smiley);
7735
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2435 if(annipixbuf) {
7792
27f55b264446 [gaim-migrate @ 8438]
Sean Egan <seanegan@gmail.com>
parents: 7787
diff changeset
2436 if(gdk_pixbuf_animation_is_static_image(annipixbuf)) {
7735
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2437 pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2438 if(pixbuf)
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2439 icon = gtk_image_new_from_pixbuf(pixbuf);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2440 } else {
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2441 icon = gtk_image_new_from_animation(annipixbuf);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2442 }
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2443 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2444
7735
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2445 if (icon) {
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2446 gtk_widget_show(icon);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2447 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), icon, anchor);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2448 }
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2449 }
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2450
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2451 int span_compare_begin(const GtkIMHtmlFormatSpan *a, const GtkIMHtmlFormatSpan *b, GtkTextBuffer *buffer)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2452 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2453 GtkTextIter ia, ib;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2454 gtk_text_buffer_get_iter_at_mark(buffer, &ia, a->start);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2455 gtk_text_buffer_get_iter_at_mark(buffer, &ib, b->start);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2456 return gtk_text_iter_compare(&ia, &ib);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2457 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2458
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2459 int span_compare_end(GtkIMHtmlFormatSpan *a, GtkIMHtmlFormatSpan *b)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2460 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2461 GtkTextIter ia, ib;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2462 gtk_text_buffer_get_iter_at_mark(a->buffer, &ia, a->start);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2463 gtk_text_buffer_get_iter_at_mark(b->buffer, &ib, b->start);
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
2464 /* The -1 here makes it so that if I have two spans that close at the same point, the
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2465 * span added second will be closed first, as in <b><i>Hello</i></b>. Without this,
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
2466 * it would be <b><i>Hello</b></i> */
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
2467 return gtk_text_iter_compare(&ia, &ib) - 1;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2468 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2469
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2470 /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2471 * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2472 * check the list of formatted strings, sorted by the position of the starting tags and apply them as
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2473 * needed. After applying the start tags, add the end tags to the "closers" list, which is sorted by
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2474 * location of ending tags. These get applied in a similar fashion. Finally, replace <, >, &, and "
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2475 * with their HTML equivilent. */
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2476 char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end)
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2477 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2478 gunichar c;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2479 GtkIMHtmlFormatSpan *sspan = NULL, *espan = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2480 GtkTextIter iter, siter, eiter;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2481 GList *starters = imhtml->format_spans;
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2482 GList *closers = NULL;
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2483 GString *str = g_string_new("");
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2484 g_list_sort_with_data(starters, (GCompareDataFunc)span_compare_begin, imhtml->text_buffer);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2485
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2486 gtk_text_iter_order(start, end);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2487 iter = *start;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2488
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2489
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2490 /* Initialize these to the end iter */
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2491 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &siter);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2492 eiter = siter;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2493
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2494 if (starters) {
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2495 while (starters) {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2496 GtkTextIter tagend;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2497 sspan = (GtkIMHtmlFormatSpan*)starters->data;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2498 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &siter, sspan->start);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2499 if (gtk_text_iter_compare(&siter, start) > 0)
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2500 break;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2501 if (sspan->end)
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2502 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &tagend, sspan->end);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2503 if (sspan->end == NULL || gtk_text_iter_compare(&tagend, start) > 0) {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2504 str = g_string_append(str, sspan->start_tag);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2505 closers = g_list_append(closers, sspan);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2506 }
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2507 sspan = (GtkIMHtmlFormatSpan*)starters->data;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2508 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &siter, sspan->start);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2509 starters = starters->next;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2510 }
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2511 if (!starters) {
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2512 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &siter);
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2513 sspan = NULL;
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2514 }
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2515 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2516
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2517 while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) {
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2518 if (c == 0xFFFC) {
7735
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2519 GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter);
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2520 char *text = g_object_get_data(G_OBJECT(anchor), "text_tag");
edebf99a5ec4 [gaim-migrate @ 8380]
Sean Egan <seanegan@gmail.com>
parents: 7734
diff changeset
2521 str = g_string_append(str, text);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2522 } else {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2523 while (gtk_text_iter_equal(&eiter, &iter)) {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2524 /* This is where we shall insert the ending tag of
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2525 * this format span */
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2526 str = g_string_append(str, espan->end_tag);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2527 closers = g_list_remove(closers, espan);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2528 if (!closers) {
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2529 espan = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2530 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &eiter);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2531 } else {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2532 espan = (GtkIMHtmlFormatSpan*)closers->data;
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2533 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &eiter, espan->end);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2534 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2535 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2536 while (gtk_text_iter_equal(&siter, &iter)) {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2537 /* This is where we shall insert the starting tag of
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2538 * this format span */
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2539 str = g_string_append(str, sspan->start_tag);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2540 if (sspan->end) {
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2541 //espan = sspan;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2542 //gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &eiter, espan->end);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2543 closers = g_list_insert_sorted(closers, sspan, (GCompareFunc)span_compare_end);
7779
de9a47ff006a [gaim-migrate @ 8424]
Sean Egan <seanegan@gmail.com>
parents: 7778
diff changeset
2544 espan = (GtkIMHtmlFormatSpan*)closers->data;
de9a47ff006a [gaim-migrate @ 8424]
Sean Egan <seanegan@gmail.com>
parents: 7778
diff changeset
2545 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &eiter, espan->end);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2546
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2547 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2548 starters = starters->next;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2549 if (starters) {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2550 sspan = (GtkIMHtmlFormatSpan*)starters->data;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2551 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &siter, sspan->start);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2552 } else {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2553 sspan = NULL;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2554 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &siter);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2555 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2556
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2557 }
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2558
7715
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2559 if (c == '<')
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2560 str = g_string_append(str, "&lt;");
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2561 else if (c == '>')
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2562 str = g_string_append(str, "&gt;");
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2563 else if (c == '&')
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2564 str = g_string_append(str, "&amp;");
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2565 else if (c == '"')
9f6dc7b4fc57 [gaim-migrate @ 8360]
Sean Egan <seanegan@gmail.com>
parents: 7714
diff changeset
2566 str = g_string_append(str, "&quot;");
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2567 else if (c == '\n')
7808
4707d8436806 [gaim-migrate @ 8455]
Sean Egan <seanegan@gmail.com>
parents: 7807
diff changeset
2568 str = g_string_append(str, "<br>");
7716
911f03121652 [gaim-migrate @ 8361]
Sean Egan <seanegan@gmail.com>
parents: 7715
diff changeset
2569 else
911f03121652 [gaim-migrate @ 8361]
Sean Egan <seanegan@gmail.com>
parents: 7715
diff changeset
2570 str = g_string_append_unichar(str, c);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2571 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2572 gtk_text_iter_forward_char(&iter);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2573 }
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
2574 closers = g_list_reverse(closers);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2575 while (closers) {
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2576 GtkIMHtmlFormatSpan *span = (GtkIMHtmlFormatSpan*)closers->data;
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2577 str = g_string_append(str, span->end_tag);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2578 closers = g_list_remove(closers, span);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2579
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2580 }
7807
317f43c8287c [gaim-migrate @ 8454]
Sean Egan <seanegan@gmail.com>
parents: 7801
diff changeset
2581 printf("Gotten: %s\n", str->str);
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2582 return g_string_free(str, FALSE);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2583 }
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2584
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2585 void gtk_imhtml_close_tags(GtkIMHtml *imhtml)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2586 {
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2587
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2588 if (imhtml->edit.bold)
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2589 gtk_imhtml_toggle_bold(imhtml);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2590
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2591 if (imhtml->edit.italic)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2592 gtk_imhtml_toggle_italic(imhtml);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2593
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2594 if (imhtml->edit.underline)
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2595 gtk_imhtml_toggle_underline(imhtml);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2596
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2597 if (imhtml->edit.forecolor)
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2598 gtk_imhtml_toggle_forecolor(imhtml, NULL);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2599
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2600 if (imhtml->edit.backcolor)
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2601 gtk_imhtml_toggle_backcolor(imhtml, NULL);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2602
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2603 if (imhtml->edit.fontface)
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2604 gtk_imhtml_toggle_fontface(imhtml, NULL);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2605
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2606 if (imhtml->edit.sizespan)
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2607 gtk_imhtml_font_set_size(imhtml, -1);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2608
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2609 }
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2610
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2611 char *gtk_imhtml_get_markup(GtkIMHtml *imhtml)
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2612 {
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2613 char *text;
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2614 GtkTextIter start, end;
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2615
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2616 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2617 // gtk_text_iter_backward_char(&start);
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2618 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2619 text = gtk_imhtml_get_markup_range(imhtml, &start, &end);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2620
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2621 // return gtk_imhtml_get_markup_range(imhtml, &start, &end);
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2622 return text;
7749
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2623 }
ddda7537918e [gaim-migrate @ 8394]
Sean Egan <seanegan@gmail.com>
parents: 7745
diff changeset
2624
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2625 char *gtk_imhtml_get_text(GtkIMHtml *imhtml)
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2626 {
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2627 GtkTextIter start_iter, end_iter;
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2628 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start_iter);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2629 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end_iter);
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2630 return gtk_text_buffer_get_text(imhtml->text_buffer, &start_iter, &end_iter, FALSE);
7809
533419ef5569 [gaim-migrate @ 8456]
Nathan Walp <nwalp@pidgin.im>
parents: 7808
diff changeset
2631
7694
6a9acef3b867 [gaim-migrate @ 8339]
Sean Egan <seanegan@gmail.com>
parents: 7404
diff changeset
2632 }
7778
3db18c16f573 [gaim-migrate @ 8423]
Sean Egan <seanegan@gmail.com>
parents: 7766
diff changeset
2633