annotate src/gtkimhtml.c @ 4130:391fd7aebe7c

[gaim-migrate @ 4348] used to be winerror.h committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 24 Dec 2002 19:41:04 +0000
parents 4a3f863b041f
children 6b2d0ce7fb18
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"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include <gtk/gtk.h>
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
27 #include <gdk/gdkkeysyms.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <stdio.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <math.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
32 #ifdef HAVE_LANGINFO_CODESET
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
33 #include <langinfo.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
34 #include <locale.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
35 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
37
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
38 /* 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
39 * 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
40 #define MAX_FONT_SIZE 7
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
41 #define POINT_SIZE(x) (_point_sizes [MIN ((x), MAX_FONT_SIZE) - 1])
3928
fb60cd7a2506 [gaim-migrate @ 4100]
Sean Egan <seanegan@gmail.com>
parents: 3922
diff changeset
42 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
43
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
44 /* The four elements present in a <FONT> tag contained in a struct */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
45 typedef struct _FontDetail FontDetail;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 struct _FontDetail {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 gushort size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 gchar *face;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
49 gchar *fore;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
50 gchar *back;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
51 gchar *sml;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
54 struct _GtkSmileyTree {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
55 GString *values;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
56 GtkSmileyTree **children;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
57 gchar *image;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
58 };
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
59
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
60 static GtkSmileyTree*
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
61 gtk_smiley_tree_new ()
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
62 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
63 return g_new0 (GtkSmileyTree, 1);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
64 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
65
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
66 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
67 gtk_smiley_tree_insert (GtkSmileyTree *tree,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
68 const gchar *text,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
69 const gchar *path)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
70 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
71 GtkSmileyTree *t = tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
72 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
73
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
74 if (!strlen (x))
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
75 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
76
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
77 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
78 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
79 gint index;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
80
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
81 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
82 t->values = g_string_new ("");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
83
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
84 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
85 if (!pos) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
86 t->values = g_string_append_c (t->values, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
87 index = t->values->len - 1;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
88 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
89 t->children [index] = g_new0 (GtkSmileyTree, 1);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
90 } else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
91 index = (int) pos - (int) t->values->str;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
92
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
93 t = t->children [index];
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
94
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
95 x++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
96 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
97
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
98 t->image = path;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
99 }
4041
3a36ec242415 [gaim-migrate @ 4249]
Sean Egan <seanegan@gmail.com>
parents: 4032
diff changeset
100
3a36ec242415 [gaim-migrate @ 4249]
Sean Egan <seanegan@gmail.com>
parents: 4032
diff changeset
101 gboolean gtk_smiley_tree_destroy (GtkSmileyTree *tree)
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
102 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
103 GSList *list = g_slist_append (NULL, tree);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
104
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
105 while (list) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
106 GtkSmileyTree *t = list->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
107 gint i;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
108 list = g_slist_remove(list, t);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
109 if (t->values) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
110 for (i = 0; i < t->values->len; i++)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
111 list = g_slist_append (list, t->children [i]);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
112 g_string_free (t->values, TRUE);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
113 g_free (t->children);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
114 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
115 g_free (t);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
116 }
4041
3a36ec242415 [gaim-migrate @ 4249]
Sean Egan <seanegan@gmail.com>
parents: 4032
diff changeset
117 return TRUE;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
118 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
119
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
120 static GtkTextViewClass *parent_class = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
121
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
122
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
123 /* GtkIMHtml has one signal--URL_CLICKED */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 LAST_SIGNAL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
130 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
131 gtk_imhtml_finalize (GObject *object)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
132 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
133 GtkIMHtml *imhtml = GTK_IMHTML(object);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
134
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
135 g_hash_table_foreach_remove(imhtml->smiley_data, gtk_smiley_tree_destroy, NULL);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
136 gtk_smiley_tree_destroy(imhtml->default_smilies);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
137 G_OBJECT_CLASS(parent_class)->finalize (object);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
138 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
140 /* Boring GTK stuff */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
141 static void gtk_imhtml_class_init (GtkIMHtmlClass *class)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
143 GtkObjectClass *object_class;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
144 GObjectClass *gobject_class;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
145 object_class = (GtkObjectClass*) class;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
146 gobject_class = (GObjectClass*) class;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
147 parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
148 signals[URL_CLICKED] = gtk_signal_new("url_clicked",
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
149 GTK_RUN_FIRST,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
150 GTK_CLASS_TYPE(object_class),
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
151 GTK_SIGNAL_OFFSET(GtkIMHtmlClass, url_clicked),
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
152 gtk_marshal_NONE__POINTER,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
153 GTK_TYPE_NONE, 1,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
154 GTK_TYPE_POINTER);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
155 gobject_class->finalize = gtk_imhtml_finalize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
158 static void gtk_imhtml_init (GtkIMHtml *imhtml)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
160 GtkTextIter iter;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
161 imhtml->text_buffer = gtk_text_buffer_new(NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
162 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
163 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
164 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
165 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
166 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), FALSE);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
167 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
168 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), FALSE);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
169 /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/
3465
ec437d73b2ee [gaim-migrate @ 3515]
Sean Egan <seanegan@gmail.com>
parents: 3460
diff changeset
170
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
171 /* These tags will be used often and can be reused--we create them on init and then apply them by name
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
172 * other tags (color, size, face, etc.) will have to be created and applied dynamically */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
173 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
174 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
175 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
176 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
177 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
178 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
179 gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL);
3465
ec437d73b2ee [gaim-migrate @ 3515]
Sean Egan <seanegan@gmail.com>
parents: 3460
diff changeset
180
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
181 /* 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
182 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
183 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
184
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
185 imhtml->smiley_data = g_hash_table_new (g_str_hash, g_str_equal);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
186 imhtml->default_smilies = gtk_smiley_tree_new();
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
187 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
188
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
189 GtkWidget *gtk_imhtml_new(void *a, void *b)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
191 return GTK_WIDGET(gtk_type_new(gtk_imhtml_get_type()));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
194 GtkType gtk_imhtml_get_type()
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
196 static guint imhtml_type = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 if (!imhtml_type) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
199 GtkTypeInfo imhtml_info = {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 "GtkIMHtml",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 sizeof (GtkIMHtml),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 sizeof (GtkIMHtmlClass),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 (GtkClassInitFunc) gtk_imhtml_class_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 (GtkObjectInitFunc) gtk_imhtml_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 NULL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 };
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
208
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
209 imhtml_type = gtk_type_unique (gtk_text_view_get_type (), &imhtml_info);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
215 /* The call back for an event on a link tag. */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
216 void tag_event(GtkTextTag *tag, GObject *arg1, GdkEvent *event, GtkTextIter *arg2, char *url) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
217 if (event->type == GDK_BUTTON_RELEASE) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
218 /* A link was clicked--we emit the "url_clicked" signal with the URL as the argument */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
219 // if ((GdkEventButton)(event)->button == 1)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
220 gtk_signal_emit (G_OBJECT(arg1), signals[URL_CLICKED], url);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
221 } else if (event->type == GDK_ENTER_NOTIFY) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
222 /* make a hand cursor and a tooltip timeout -- if GTK worked as it should */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
223 } else if (event->type == GDK_LEAVE_NOTIFY) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
224 /* clear timeout and make an arrow cursor again --if GTK worked as it should */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
228 static void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
229 gtk_smiley_tree_remove (GtkSmileyTree *tree,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
230 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
231 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
232 GtkSmileyTree *t = tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
233 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
234 gint len = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
235
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
236 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
237 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
238
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
239 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
240 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
241
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
242 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
243 if (pos)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
244 t = t->children [(int) pos - (int) t->values->str];
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
245 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
246 return;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
247
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
248 x++; len++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
249 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
250
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
251 if (t->image)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
252 t->image = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
253 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
254
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
255 static gint
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
256 gtk_smiley_tree_lookup (GtkSmileyTree *tree,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
257 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
258 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
259 GtkSmileyTree *t = tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
260 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
261 gint len = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
262
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
263 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
264 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
265
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
266 if (!t->values)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
267 break;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
268
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
269 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
270 if (pos)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
271 t = t->children [(int) pos - (int) t->values->str];
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
272 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
273 break;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
274
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
275 x++; len++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
276 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
277
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
278 if (t->image)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
279 return len;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
280
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
281 return 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
282 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
283
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
284 void
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
285 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
286 gchar *text,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
287 gchar *sml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
288 gchar *path)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
289 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
290 GtkSmileyTree *tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
291 g_return_if_fail (imhtml != NULL);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
292 g_return_if_fail (GTK_IS_IMHTML (imhtml));
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
293 g_return_if_fail (text != NULL);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
294
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
295 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
296 tree = imhtml->default_smilies;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
297 else if ((tree = g_hash_table_lookup(imhtml->smiley_data, sml))) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
298 } else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
299 tree = gtk_smiley_tree_new();
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
300 g_hash_table_insert(imhtml->smiley_data, sml, tree);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
301 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
302
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
303 if (path == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
304 gtk_smiley_tree_remove (tree, text);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
305 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
306 gtk_smiley_tree_insert (tree, text, path);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
307 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
308
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
309 static gboolean
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
310 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
311 GSList *fonts,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
312 const gchar *text,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
313 gint *len)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
314 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
315 GtkSmileyTree *tree;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
316 FontDetail *font;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
317 char *sml = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
318
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
319 if (fonts) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
320 font = fonts->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
321 sml = font->sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
322 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
323
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
324 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
325 tree = imhtml->default_smilies;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
326 else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
327 tree = g_hash_table_lookup(imhtml->smiley_data, sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
328 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
329 if (tree == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
330 return FALSE;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
331
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
332 *len = gtk_smiley_tree_lookup (tree, text);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
333 return (*len > 0);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
334 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
335
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
336 static gchar*
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
337 gtk_smiley_tree_image (GtkIMHtml *imhtml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
338 const gchar *sml,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
339 const gchar *text)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
340 {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
341 GtkSmileyTree *t;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
342 const gchar *x = text;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
343
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
344 if (sml == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
345 t = imhtml->default_smilies;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
346 else
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
347 t = g_hash_table_lookup(imhtml->smiley_data, sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
348
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
349
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
350 if (t == NULL)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
351 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
352
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
353 while (*x) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
354 gchar *pos;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
355
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
356 if (!t->values) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
357 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
358 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
359
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
360 pos = strchr (t->values->str, *x);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
361 if (pos) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
362 t = t->children [(int) pos - (int) t->values->str];
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
363 } else {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
364 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
365 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
366 x++;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
367 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
368
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
369 return t->image;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
370 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
371 #define VALID_TAG(x) if (!g_strncasecmp (string, x ">", strlen (x ">"))) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
372 *tag = g_strndup (string, strlen (x)); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
373 *len = strlen (x) + 1; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
374 return TRUE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
375 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
376 (*type)++
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
378 #define VALID_OPT_TAG(x) if (!g_strncasecmp (string, x " ", strlen (x " "))) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
379 const gchar *c = string + strlen (x " "); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
380 gchar e = '"'; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
381 gboolean quote = FALSE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
382 while (*c) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
383 if (*c == '"' || *c == '\'') { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
384 if (quote && (*c == e)) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
385 quote = !quote; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
386 else if (!quote) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
387 quote = !quote; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
388 e = *c; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
389 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
390 } else if (!quote && (*c == '>')) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
391 break; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
392 c++; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
393 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
394 if (*c) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
395 *tag = g_strndup (string, c - string); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
396 *len = c - string + 1; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
397 return TRUE; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
398 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
399 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
400 (*type)++
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
403 static gboolean
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
404 gtk_imhtml_is_amp_escape (const gchar *string,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
405 gchar *replace,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
406 gint *length)
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
407 {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
408 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
409 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
410 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
411
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
412 if (!g_strncasecmp (string, "&amp;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
413 *replace = '&';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
414 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
415 } else if (!g_strncasecmp (string, "&lt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
416 *replace = '<';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
417 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
418 } else if (!g_strncasecmp (string, "&gt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
419 *replace = '>';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
420 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
421 } else if (!g_strncasecmp (string, "&nbsp;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
422 *replace = ' ';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
423 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
424 } else if (!g_strncasecmp (string, "&copy;", 6)) {
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3705
diff changeset
425 *replace = '©'; /* was: '©' */
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
426 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
427 } else if (!g_strncasecmp (string, "&quot;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
428 *replace = '\"';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
429 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
430 } else if (!g_strncasecmp (string, "&reg;", 5)) {
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3705
diff changeset
431 *replace = '®'; /* was: '®' */
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
432 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
433 } else if (*(string + 1) == '#') {
2022
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
434 guint pound = 0;
3004
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 3000
diff changeset
435 if ((sscanf (string, "&#%u;", &pound) == 1) && pound != 0) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
436 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
437 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
438 *replace = (gchar)pound;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
439 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
440 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
441 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
442 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
443 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
444 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
445 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
446 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
447 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
448
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
449 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
450 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
451
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
452 static gboolean
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
453 gtk_imhtml_is_tag (const gchar *string,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
454 gchar **tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
455 gint *len,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
456 gint *type)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
457 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
458 *type = 1;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
459
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
460 if (!strchr (string, '>'))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
461 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
462
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
463 VALID_TAG ("B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
464 VALID_TAG ("BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
465 VALID_TAG ("/B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
466 VALID_TAG ("/BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
467 VALID_TAG ("I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
468 VALID_TAG ("ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
469 VALID_TAG ("/I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
470 VALID_TAG ("/ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
471 VALID_TAG ("U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
472 VALID_TAG ("UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
473 VALID_TAG ("/U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
474 VALID_TAG ("/UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
475 VALID_TAG ("S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
476 VALID_TAG ("STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
477 VALID_TAG ("/S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
478 VALID_TAG ("/STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
479 VALID_TAG ("SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
480 VALID_TAG ("/SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
481 VALID_TAG ("SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
482 VALID_TAG ("/SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
483 VALID_TAG ("PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
484 VALID_TAG ("/PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
485 VALID_TAG ("TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
486 VALID_TAG ("/TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
487 VALID_TAG ("BR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
488 VALID_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
489 VALID_TAG ("/FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
490 VALID_TAG ("/A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
491 VALID_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
492 VALID_TAG ("/P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
493 VALID_TAG ("H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
494 VALID_TAG ("/H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
495 VALID_TAG ("HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
496 VALID_TAG ("/HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
497 VALID_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
498 VALID_TAG ("/BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
499 VALID_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
500 VALID_TAG ("HEAD");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
501 VALID_TAG ("/HEAD");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
502 VALID_TAG ("BINARY");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
503 VALID_TAG ("/BINARY");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
504
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
505 VALID_OPT_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
506 VALID_OPT_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
507 VALID_OPT_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
508 VALID_OPT_TAG ("A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
509 VALID_OPT_TAG ("IMG");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
510 VALID_OPT_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
511 VALID_OPT_TAG ("H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
512
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
513 if (!g_strncasecmp(string, "!--", strlen ("!--"))) {
2954
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
514 gchar *e = strstr (string + strlen("!--"), "-->");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
515 if (e) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
516 *len = e - string + strlen ("-->");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
517 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->"));
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
518 return TRUE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
519 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
520 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
521
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
522 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
523 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
524
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
525 static gchar*
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
526 gtk_imhtml_get_html_opt (gchar *tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
527 const gchar *opt)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
528 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
529 gchar *t = tag;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
530 gchar *e, *a;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
531
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
532 while (g_strncasecmp (t, opt, strlen (opt))) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
533 gboolean quote = FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
534 if (*t == '\0') break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
535 while (*t && !((*t == ' ') && !quote)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
536 if (*t == '\"')
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
537 quote = ! quote;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
538 t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
539 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
540 while (*t && (*t == ' ')) t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
541 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
542
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
543 if (!g_strncasecmp (t, opt, strlen (opt))) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
544 t += strlen (opt);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
545 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
546 return NULL;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
547 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
548
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
549 if ((*t == '\"') || (*t == '\'')) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
550 e = a = ++t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
551 while (*e && (*e != *(t - 1))) e++;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
552 if (*e == '\0') {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
553 return NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
554 } else
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
555 return g_strndup (a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
556 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
557 e = a = t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
558 while (*e && !isspace ((gint) *e)) e++;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
559 return g_strndup (a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
560 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
561 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
562
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
563
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
564
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
565 #define NEW_TEXT_BIT 0
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
566 #define NEW_HR_BIT 1
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
567 #define NEW_BIT(x) ws [wpos] = '\0'; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
568 mark2 = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
569 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, -1); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
570 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
571 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &siter, mark2); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
572 gtk_text_buffer_delete_mark(imhtml->text_buffer, mark2); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
573 if (bold) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
574 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
575 if (italics) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
576 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
577 if (underline) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
578 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
579 if (strike) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
580 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
581 if (sub) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
582 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
583 if (sup) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
584 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
585 if (pre) \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
586 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
587 if (bg) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
588 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
589 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
590 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
591 if (fonts) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
592 FontDetail *fd = fonts->data; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
593 if (fd->fore) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
594 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
595 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
596 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
597 if (fd->back) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
598 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
599 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
600 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
601 if (fd->face) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
602 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "font", fd->face, NULL); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
603 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
604 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
605 if (fd->size) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
606 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "size-points", (double)POINT_SIZE(fd->size), NULL); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
607 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
608 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
609 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
610 if (url) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
611 texttag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
612 g_signal_connect(G_OBJECT(texttag), "event", G_CALLBACK(tag_event), strdup(url)); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
613 gtk_text_buffer_apply_tag(imhtml->text_buffer, texttag, &siter, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
614 } \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
615 wpos = 0; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
616 ws[0] = 0; \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
617 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
618
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
619
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
620 /* if (x == NEW_HR_BIT) { \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
621 sep = gtk_hseparator_new(); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
622 gtk_widget_size_request(GTK_WIDGET(imhtml), &req); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
623 gtk_widget_set_size_request(sep, 20, -1); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
624 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, &iter); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
625 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), sep, anchor); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
626 gtk_widget_show(sep); \
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
627 } */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
628
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
629 GString* gtk_imhtml_append_text (GtkIMHtml *imhtml,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
630 const gchar *text,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
631 gint len,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
632 GtkIMHtmlOptions options)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
634 gint pos = 0;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
635 GString *str = NULL;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
636 GtkTextIter iter, siter;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
637 GtkTextMark *mark, *mark2;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
638 GtkTextChildAnchor *anchor;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
639 GtkTextTag *texttag;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
640 GtkWidget *sep;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
641 GtkRequisition req;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
642 gchar *ws;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
643 gchar *tag;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
644 gchar *url = NULL;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
645 gchar *bg = NULL;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
646 gint tlen, smilelen, wpos=0;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
647 gint type;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
648 const gchar *c;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
649 gchar amp;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
650
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
657 title = 0,
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
658 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
660 GSList *fonts = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 g_return_val_if_fail (text != NULL, NULL);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
665 g_return_val_if_fail (len != 0, NULL);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
666
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
667 c = text;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
668 if (len == -1)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
669 len = strlen(text);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
670 ws = g_malloc(len + 1);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
671 ws[0] = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 if (options & GTK_IMHTML_RETURN_LOG)
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
674 str = g_string_new("");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
676 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
677 mark = gtk_text_buffer_create_mark (imhtml->text_buffer, NULL, &iter, /* right grav */ FALSE);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
678 while (pos < len) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
679 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
680 c++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
681 pos++;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
682 switch (type)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
683 {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
684 case 1: /* B */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
685 case 2: /* BOLD */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
686 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
687 bold++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
688 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
689 case 3: /* /B */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
690 case 4: /* /BOLD */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
691 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
692 if (bold)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
693 bold--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
694 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
695 case 5: /* I */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
696 case 6: /* ITALIC */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
697 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
698 italics++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
699 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
700 case 7: /* /I */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
701 case 8: /* /ITALIC */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
702 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
703 if (italics)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
704 italics--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
705 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
706 case 9: /* U */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
707 case 10: /* UNDERLINE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
708 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
709 underline++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
710 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
711 case 11: /* /U */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
712 case 12: /* /UNDERLINE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
713 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
714 if (underline)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
715 underline--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
716 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
717 case 13: /* S */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
718 case 14: /* STRIKE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
719 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
720 strike++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
721 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
722 case 15: /* /S */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
723 case 16: /* /STRIKE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
724 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
725 if (strike)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
726 strike--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
727 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
728 case 17: /* SUB */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
729 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
730 sub++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
731 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
732 case 18: /* /SUB */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
733 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
734 if (sub)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
735 sub--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
736 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
737 case 19: /* SUP */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
738 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
739 sup++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
740 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
741 case 20: /* /SUP */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
742 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
743 if (sup)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
744 sup--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
745 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
746 case 21: /* PRE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
747 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
748 pre++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
749 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
750 case 22: /* /PRE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
751 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
752 if (pre)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
753 pre--;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
754 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
755 case 23: /* TITLE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
756 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
757 title++;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
758 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
759 case 24: /* /TITLE */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
760 if (title) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
761 if (options & GTK_IMHTML_NO_TITLE) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
762 wpos = 0;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
763 ws [wpos] = '\0';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
764 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
765 title--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
766 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
767 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
768 case 25: /* BR */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
769 ws[wpos] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
770 wpos++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
771 NEW_BIT (NEW_TEXT_BIT);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
772 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
773 case 26: /* HR */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
774 case 42: /* HR (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
775 ws[wpos++] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
776 NEW_BIT(NEW_HR_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
777 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
778 case 27: /* /FONT */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
779 if (fonts) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
780 FontDetail *font = fonts->data;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
781 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
782 fonts = g_slist_remove (fonts, font);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
783 if (font->face)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
784 g_free (font->face);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
785 if (font->fore)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
786 g_free (font->fore);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
787 if (font->back)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
788 g_free (font->back);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
789 if (font->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
790 g_free (font->sml);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
791 g_free (font);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
792 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
793 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
794 case 28: /* /A */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
795 if (url) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
796 NEW_BIT(NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
797 g_free(url);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
798 url = NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
799 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
800 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
801 case 29: /* P */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
802 case 30: /* /P */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
803 case 31: /* H3 */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
804 case 32: /* /H3 */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
805 case 33: /* HTML */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
806 case 34: /* /HTML */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
807 case 35: /* BODY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
808 case 36: /* /BODY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
809 case 37: /* FONT */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
810 case 38: /* HEAD */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
811 case 39: /* /HEAD */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
812 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
813 case 40: /* BINARY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
814 case 41: /* /BINARY */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
815 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
816 case 43: /* FONT (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
817 {
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
818 gchar *color, *back, *face, *size, *sml;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
819 FontDetail *font, *oldfont = NULL;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
820 color = gtk_imhtml_get_html_opt (tag, "COLOR=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
821 back = gtk_imhtml_get_html_opt (tag, "BACK=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
822 face = gtk_imhtml_get_html_opt (tag, "FACE=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
823 size = gtk_imhtml_get_html_opt (tag, "SIZE=");
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
824 sml = gtk_imhtml_get_html_opt (tag, "SML=");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
825 if (!(color || back || face || size || sml))
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
826 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
827
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
828 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
829
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
830 font = g_new0 (FontDetail, 1);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
831 if (fonts)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
832 oldfont = fonts->data;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
833
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
834 if (color && !(options & GTK_IMHTML_NO_COLOURS))
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
835 font->fore = color;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
836 else if (oldfont && oldfont->fore)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
837 font->fore = g_strdup(oldfont->fore);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
838
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
839 if (back && !(options & GTK_IMHTML_NO_COLOURS))
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
840 font->back = back;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
841 else if (oldfont && oldfont->back)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
842 font->back = g_strdup(oldfont->back);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
843
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
844 if (face && !(options & GTK_IMHTML_NO_FONTS))
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
845 font->face = face;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
846 else if (oldfont && oldfont->face)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
847 font->face = g_strdup(oldfont->face);
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
848
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
849 if (sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
850 font->sml = sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
851 else if (oldfont && oldfont->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
852 font->sml = g_strdup(oldfont->sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
853
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
854 if (size && !(options & GTK_IMHTML_NO_SIZES)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
855 if (*size == '+') {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
856 sscanf (size + 1, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
857 font->size += 3;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
858 } else if (*size == '-') {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
859 sscanf (size + 1, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
860 font->size = MAX (0, 3 - font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
861 } else if (isdigit (*size)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
862 sscanf (size, "%hd", &font->size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
863 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
864 } else if (oldfont)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
865 font->size = oldfont->size;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
866 g_free(size);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
867 fonts = g_slist_prepend (fonts, font);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
868 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
869 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
870 case 44: /* BODY (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
871 if (!(options & GTK_IMHTML_NO_COLOURS)) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
872 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
873 if (bgcolor) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
874 NEW_BIT(NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
875 if (bg)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
876 g_free(bg);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
877 bg = bgcolor;
2885
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
878 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
880 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
881 case 45: /* A (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
882 {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
883 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF=");
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
884 if (href) {
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
885 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
886 if (url)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
887 g_free (url);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
888 url = href;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
889 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
890 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
891 break;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
892 case 47: /* P (opt) */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
893 case 48: /* H3 (opt) */
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
894 break;
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
895 case 49: /* comment */
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
896 NEW_BIT (NEW_TEXT_BIT);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
897 wpos = g_snprintf (ws, len, "%s", tag);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
898 NEW_BIT (NEW_COMMENT_BIT);
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 default:
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
901 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
902 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
903 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
904 pos += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
905 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &amp, &tlen)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
906 ws [wpos++] = amp;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
907 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
908 pos += tlen;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
911 ws[wpos] = '\n';
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
912 wpos++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
913 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
914 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
915 c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
916 pos++;
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
917 } else if (gtk_imhtml_is_smiley (imhtml, fonts, c, &smilelen) || gtk_imhtml_is_smiley(imhtml, NULL, c, &smilelen)) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
918 FontDetail *fd;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
919 gchar *sml = NULL;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
920 if (fonts) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
921 fd = fonts->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
922 sml = fd->sml;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
923 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
924 NEW_BIT (NEW_TEXT_BIT);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
925 wpos = g_snprintf (ws, smilelen + 1, "%s", c);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
926 gtk_text_buffer_insert_pixbuf(imhtml->text_buffer, &iter, gdk_pixbuf_new_from_file(gtk_smiley_tree_image (imhtml, sml, ws), NULL));
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
927 c += smilelen;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
928 pos += smilelen;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
929 wpos = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
930 ws[0] = 0;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
931 } else if (*c) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932 ws [wpos++] = *c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
933 pos++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
934 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
935 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
938
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
939 NEW_BIT(NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 g_free (url);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
942 if (str)
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
943 str = g_string_append (str, "</A>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
944 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
945
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
946 while (fonts) {
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
947 FontDetail *font = fonts->data;
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
948 fonts = g_slist_remove (fonts, font);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
949 if (font->face)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
950 g_free (font->face);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
951 if (font->fore)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
952 g_free (font->fore);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
953 if (font->back)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
954 g_free (font->back);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
955 if (font->sml)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
956 g_free (font->sml);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
957 g_free (font);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
958 if (str)
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
959 str = g_string_append (str, "</FONT>");
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
960 }
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
961
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
962 if (str) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 while (bold) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
964 str = g_string_append (str, "</B>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967 while (italics) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
968 str = g_string_append (str, "</I>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 while (underline) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
972 str = g_string_append (str, "</U>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 while (strike) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
976 str = g_string_append (str, "</S>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 while (sub) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
980 str = g_string_append (str, "</SUB>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 while (sup) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
984 str = g_string_append (str, "</SUP>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 while (title) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
988 str = g_string_append (str, "</TITLE>");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
991 while (pre) {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
992 str = g_string_append (str, "</PRE>");
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
993 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
994 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 }
4032
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
996 g_free (ws);
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
997 if (!(options & GTK_IMHTML_NO_SCROLL))
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
998 gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (imhtml), mark,
2b3a9d8f168e [gaim-migrate @ 4238]
Sean Egan <seanegan@gmail.com>
parents: 3941
diff changeset
999 0, TRUE, 0.0, 1.0);
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1000 gtk_text_buffer_delete_mark (imhtml->text_buffer, mark);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1001 return str;
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1002 }
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1003
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1004 void gtk_imhtml_set_img_handler (GtkIMHtml *imhtml,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1005 GtkIMHtmlImage handler){}
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1006
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1007 void gtk_imhtml_remove_smileys (GtkIMHtml *imhtml){}
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1008 void gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1009 gboolean show){}
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1010
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1011 void gtk_imhtml_show_comments (GtkIMHtml *imhtml,
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1012 gboolean show){}
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1013
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1014 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1015 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1016 {
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1017 GtkTextIter start, end;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1018
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1019 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1020 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1021 gtk_text_buffer_delete(imhtml->text_buffer, &start, &end);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
1022 }
2363
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
1023
4046
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1024 void gtk_imhtml_page_up (GtkIMHtml *imhtml)
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1025 {
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1026
4a3f863b041f [gaim-migrate @ 4254]
Sean Egan <seanegan@gmail.com>
parents: 4041
diff changeset
1027 }
3922
30f52e7afd1d [gaim-migrate @ 4094]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1028 void gtk_imhtml_page_down (GtkIMHtml *imhtml){}