annotate src/gtkimhtml.c @ 2686:7b21c5446baf

[gaim-migrate @ 2699] hi committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 07 Nov 2001 08:03:20 +0000
parents ffa58bbe595d
children 5a207e155c15
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"
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
26 #include <X11/Xlib.h>
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
27 #include <gdk/gdkx.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <gtk/gtk.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <stdio.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <math.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
33 #ifdef HAVE_LANGINFO_CODESET
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
34 #include <langinfo.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
35 #include <locale.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
36 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
38 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
39 #define GTK_IMHTML_GET_STYLE_FONT(style) gtk_style_get_font (style)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
40 #else
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
41 #define GTK_IMHTML_GET_STYLE_FONT(style) (style)->font
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
42 #define GTK_CLASS_TYPE(class) (class)->type
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
43 #endif
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
44
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #include "pixmaps/angel.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include "pixmaps/bigsmile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include "pixmaps/burp.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #include "pixmaps/crossedlips.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #include "pixmaps/cry.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #include "pixmaps/embarrassed.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #include "pixmaps/kiss.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #include "pixmaps/moneymouth.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #include "pixmaps/sad.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #include "pixmaps/scream.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #include "pixmaps/smile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #include "pixmaps/smile8.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #include "pixmaps/think.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 #include "pixmaps/tongue.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #include "pixmaps/wink.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 #include "pixmaps/yell.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #define DEFAULT_FONT_NAME "helvetica"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 #define MAX_SIZE 7
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
64 #define MAX_FONTS 32767
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 gint font_sizes [] = { 80, 100, 120, 140, 200, 300, 400 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
68 #define BORDER_SIZE 2
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
69 #define TOP_BORDER 10
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 #define MIN_HEIGHT 20
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 #define HR_HEIGHT 2
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
72 #define TOOLTIP_TIMEOUT 500
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
74 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
75 #define COLOR_MOD 0x8000
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
76 #define COLOR_DIFF 0x800
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
77
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 #define TYPE_TEXT 0
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 #define TYPE_SMILEY 1
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 #define TYPE_IMG 2
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 #define TYPE_SEP 3
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 #define TYPE_BR 4
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 #define TYPE_COMMENT 5
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
85 #define DRAW_IMG(x) (((x)->type == TYPE_IMG) || (imhtml->smileys && ((x)->type == TYPE_SMILEY)))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
86
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 typedef struct _GtkIMHtmlBit GtkIMHtmlBit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 typedef struct _FontDetail FontDetail;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
90 struct _GtkSmileyTree {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
91 GString *values;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
92 GtkSmileyTree **children;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
93 gchar **image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
94 };
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
95
2596
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
96 static gchar*
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
97 getcharset ()
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
98 {
2596
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
99 static gchar charset [64];
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
100 #ifdef HAVE_LANGINFO_CODESET
2596
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
101 gchar *ch = nl_langinfo (CODESET);
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
102 if (!g_strncasecmp (ch, "iso-", 4))
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
103 g_snprintf (charset, sizeof (charset), "iso%s", ch + 4);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
104 else
2596
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
105 g_snprintf (charset, sizeof (charset), ch);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
106 #else
2596
35c23df11d16 [gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2583
diff changeset
107 g_snprintf (charset, sizeof (charset), "iso8859-*");
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
108 #endif
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
109 return charset;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
110 }
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
111
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
112 static GtkSmileyTree*
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
113 gtk_smiley_tree_new ()
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
114 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
115 return g_new0 (GtkSmileyTree, 1);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
116 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
117
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
118 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
119 gtk_smiley_tree_insert (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
120 const gchar *text,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
121 gchar **image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
122 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
123 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
124 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
125
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
126 if (!strlen (x))
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
127 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
128
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
129 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
130 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
131 gint index;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
132
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
133 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
134 t->values = g_string_new ("");
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
135
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
136 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
137 if (!pos) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
138 t->values = g_string_append_c (t->values, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
139 index = t->values->len - 1;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
140 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
141 t->children [index] = g_new0 (GtkSmileyTree, 1);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
142 } else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
143 index = (int) pos - (int) t->values->str;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
144
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
145 t = t->children [index];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
146
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
147 x++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
148 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
149
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
150 t->image = image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
151 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
152
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
153 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
154 gtk_smiley_tree_remove (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
155 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
156 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
157 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
158 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
159 gint len = 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
160
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
161 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
162 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
163
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
164 if (t->image) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
165 t->image = NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
166 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
167 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
168
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
169 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
170 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
171
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
172 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
173 if (pos)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
174 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
175 else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
176 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
177
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
178 x++; len++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
179 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
180
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
181 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
182 t->image = NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
183 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
184
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
185 static gint
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
186 gtk_smiley_tree_lookup (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
187 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
188 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
189 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
190 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
191 gint len = 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
192
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
193 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
194 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
195
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
196 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
197 return len;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
198
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
199 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
200 return 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
201
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
202 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
203 if (pos)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
204 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
205 else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
206 return 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
207
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
208 x++; len++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
209 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
210
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
211 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
212 return len;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
213
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
214 return 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
215 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
216
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
217 static gchar**
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
218 gtk_smiley_tree_image (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
219 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
220 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
221 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
222 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
223
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
224 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
225 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
226
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
227 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
228 return NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
229
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
230 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
231 if (pos) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
232 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
233 } else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
234 return NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
235
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
236 x++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
237 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
238
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
239 return t->image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
240 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
241
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
242 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
243 gtk_smiley_tree_destroy (GtkSmileyTree *tree)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
244 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
245 GSList *list = g_slist_append (NULL, tree);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
246
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
247 while (list) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
248 GtkSmileyTree *t = list->data;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
249 gint i;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
250 list = g_slist_remove(list, t);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
251 if (t->values) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
252 for (i = 0; i < t->values->len; i++)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
253 list = g_slist_append (list, t->children [i]);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
254 g_string_free (t->values, TRUE);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
255 g_free (t->children);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
256 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
257 g_free (t);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
258 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
259 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
260
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 struct _GtkIMHtmlBit {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 gint type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 GdkPixmap *pm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 GdkBitmap *bm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 GdkColor *bg;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 gboolean underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 gboolean strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 gchar *url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 struct _FontDetail {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 gushort size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 gchar *face;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 struct line_info {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 gint height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 gint ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 gboolean selected;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 gchar *sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 gchar *sel_end;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 struct url_widget {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 gint height;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
306 GtkIMHtml *imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
307 GtkIMHtmlBit *bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 static GtkLayoutClass *parent_class = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 TARGET_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 TARGET_TEXT,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 TARGET_COMPOUND_TEXT
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 LAST_SIGNAL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 static void gtk_imhtml_draw_bit (GtkIMHtml *, GtkIMHtmlBit *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 static GdkColor *gtk_imhtml_get_color (const gchar *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 static gint gtk_imhtml_motion_notify_event (GtkWidget *, GdkEventMotion *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 static void
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
329 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
330 gtk_imhtml_finalize (GObject *object)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
331 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 gtk_imhtml_destroy (GtkObject *object)
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
333 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 imhtml = GTK_IMHTML (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 while (imhtml->bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 GtkIMHtmlBit *bit = imhtml->bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 imhtml->bits = g_list_remove (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 if (bit->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 g_free (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 if (bit->font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 gdk_font_unref (bit->font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 if (bit->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 gdk_color_free (bit->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 if (bit->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 gdk_color_free (bit->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 if (bit->bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 gdk_color_free (bit->bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 if (bit->url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 g_free (bit->url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 if (bit->pm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 gdk_pixmap_unref (bit->pm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 if (bit->bm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 gdk_bitmap_unref (bit->bm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 while (bit->chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
359 struct line_info *li = bit->chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 if (li->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 g_free (li->text);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
362 bit->chunks = g_list_remove (bit->chunks, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 g_free (li);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 g_free (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
368 if (imhtml->line)
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
369 g_list_free (imhtml->line);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
370
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 if (imhtml->selected_text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
379 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
380 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
381 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
382 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
383 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
384 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
385 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
386 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
387 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
388
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
389 if (imhtml->default_font)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
390 gdk_font_unref (imhtml->default_font);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
391 if (imhtml->default_fg_color)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
392 gdk_color_free (imhtml->default_fg_color);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
393 if (imhtml->default_bg_color)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
394 gdk_color_free (imhtml->default_bg_color);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 gdk_cursor_destroy (imhtml->hand_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 gdk_cursor_destroy (imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
399 gtk_smiley_tree_destroy (imhtml->smiley_data);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
401 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
402 G_OBJECT_CLASS (parent_class)->finalize (object);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
403 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
406 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 gtk_imhtml_realize (GtkWidget *widget)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 GtkIMHtml *imhtml;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
413 GdkWindowAttr attributes;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
414 gint attributes_mask;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 imhtml = GTK_IMHTML (widget);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
420 GTK_WIDGET_SET_FLAGS (imhtml, GTK_REALIZED);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
421
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
422 attributes.window_type = GDK_WINDOW_CHILD;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
423 attributes.x = widget->allocation.x;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
424 attributes.y = widget->allocation.y;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
425 attributes.width = widget->allocation.width;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
426 attributes.height = widget->allocation.height;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
427 attributes.wclass = GDK_INPUT_OUTPUT;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
428 attributes.visual = gtk_widget_get_visual (widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
429 attributes.colormap = gtk_widget_get_colormap (widget);
2556
e284ab2882bd [gaim-migrate @ 2569]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
430 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
431
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
432 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
433
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
434 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
435 &attributes, attributes_mask);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
436 gdk_window_set_user_data (widget->window, widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
437
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
438 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
439 attributes.x = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
440 attributes.y = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
441 #else
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
442 attributes.x = widget->style->klass->xthickness + BORDER_SIZE;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
443 attributes.y = widget->style->klass->xthickness + BORDER_SIZE;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
444 #endif
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
445 attributes.width = MAX (1, (gint) widget->allocation.width - (gint) attributes.x * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
446 attributes.height = MAX (1, (gint) widget->allocation.height - (gint) attributes.y * 2);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
447 attributes.event_mask = gtk_widget_get_events (widget)
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
448 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
449 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
450
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
451 GTK_LAYOUT (imhtml)->bin_window = gdk_window_new (widget->window,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
452 &attributes, attributes_mask);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
453 gdk_window_set_user_data (GTK_LAYOUT (imhtml)->bin_window, widget);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 widget->style = gtk_style_attach (widget->style, widget->window);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
459 imhtml->default_font = gdk_font_ref (GTK_IMHTML_GET_STYLE_FONT (widget->style));
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
460
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
461 gdk_window_set_background (widget->window, &widget->style->base [GTK_STATE_NORMAL]);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
462 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
463 &widget->style->base [GTK_STATE_NORMAL]);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
464
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
465 imhtml->default_fg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
466 imhtml->default_bg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
467
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
468 gdk_window_show (GTK_LAYOUT (imhtml)->bin_window);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
469 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
470
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
471 static gboolean
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
472 similar_colors (GdkColor *bg,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
473 GdkColor *fg)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
474 {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
475 if ((DIFF (bg->red, fg->red) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
476 (DIFF (bg->green, fg->green) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
477 (DIFF (bg->blue, fg->blue) < COLOR_DIFF)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
478 fg->red = (0xff00 - COLOR_MOD > bg->red) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
479 bg->red + COLOR_MOD : bg->red - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
480 fg->green = (0xff00 - COLOR_MOD > bg->green) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
481 bg->green + COLOR_MOD : bg->green - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
482 fg->blue = (0xff00 - COLOR_MOD > bg->blue) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
483 bg->blue + COLOR_MOD : bg->blue - COLOR_MOD;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
484 return TRUE;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
485 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
486 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
490 draw_text (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
491 struct line_info *line)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
493 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
494 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
495 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
496 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
497 gfloat xoff, yoff;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
498 GdkColor *bg, *fg;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
499
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
500 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
501 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
502
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
503 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
504 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
505 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
506 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
507 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
508
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
509 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
510 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
511 gdk_gc_set_foreground (gc, bit->bg);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
512 bg = bit->bg;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
513 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
514 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
515 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
516 bg = imhtml->default_bg_color;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
517 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
518
2338
2bf8a8131479 [gaim-migrate @ 2351]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2337
diff changeset
519 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff,
2bf8a8131479 [gaim-migrate @ 2351]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2337
diff changeset
520 line->width ? line->width : imhtml->xsize, line->height);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
521
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
522 if (!line->text) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
523 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
524 return;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
525 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
526
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
527 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
528 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
529 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
530 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
531 gdk_string_width (bit->font, line->text), line->height);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
532 bg = bit->back;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
533 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
534
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
535 bg = gdk_color_copy (bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
536
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
537 if (line->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
538 gint width, x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
539 gchar *start, *end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
540 GdkColor col;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
541
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
542 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
543 start = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
544 end = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
545 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
546 start = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
547 end = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
548 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
549
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
550 if (start == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
551 x = 0;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
552 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
553 x = gdk_text_width (bit->font, line->text, start - line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
554
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
555 if (end == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
556 width = gdk_string_width (bit->font, line->text) - x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
557 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
558 width = gdk_text_width (bit->font, line->text, end - line->text) - x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
559
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
560 col.red = col.green = col.blue = 0xc000;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
561 gdk_color_alloc (cmap, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
562 gdk_gc_set_foreground (gc, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
563
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
564 gdk_draw_rectangle (window, gc, TRUE, x + line->x - xoff, line->y - yoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
565 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
566 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
567
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
568 if (bit->url) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
569 GdkColor *tc = gtk_imhtml_get_color ("#0000a0");
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
570 gdk_color_alloc (cmap, tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
571 gdk_gc_set_foreground (gc, tc);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
572 fg = gdk_color_copy (tc);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
573 gdk_color_free (tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
574 } else if (bit->fore) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
575 gdk_color_alloc (cmap, bit->fore);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
576 gdk_gc_set_foreground (gc, bit->fore);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
577 fg = gdk_color_copy (bit->fore);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
578 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
579 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
580 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
581 fg = gdk_color_copy (imhtml->default_fg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
582 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
583
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
584 if (similar_colors (bg, fg)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
585 gdk_color_alloc (cmap, fg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
586 gdk_gc_set_foreground (gc, fg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
587 }
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
588 gdk_color_free (bg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
589 gdk_color_free (fg);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
590
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
591 gdk_draw_string (window, bit->font, gc, line->x - xoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
592 line->y - yoff + line->ascent, line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
593
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
594 if (bit->underline || bit->url)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
595 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff + line->ascent + 1,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
596 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
597 if (bit->strike)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
598 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
599 line->y - yoff + line->ascent - (bit->font->ascent / 2),
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
600 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
601
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
602 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
603 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
604
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
605 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
606 draw_img (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
607 struct line_info *line)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
608 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
609 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
610 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
611 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
612 gint width, height, hoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
613 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
614 gfloat xoff, yoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
615
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
616 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
617 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
618
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
619 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
620 gdk_window_get_size (bit->pm, &width, &height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
621 hoff = (line->height - height) / 2;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
622 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
623 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
624 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
625 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
626
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
627 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
628 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
629 gdk_gc_set_foreground (gc, bit->bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
630 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
631 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
632 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
633 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
634
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
635 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff, line->width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
636
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
637 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
638 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
639 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
640 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
641 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
642 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
643
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
644 gdk_draw_pixmap (window, gc, bit->pm, 0, 0, line->x - xoff, line->y - yoff + hoff, -1, -1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
645
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
646 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
647 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
648
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
649 static void
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
650 draw_line (GtkIMHtml *imhtml,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
651 struct line_info *line)
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
652 {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
653 GtkIMHtmlBit *bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
654 GdkDrawable *drawable;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
655 GdkColormap *cmap;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
656 GdkGC *gc;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
657 guint line_height;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
658 gfloat xoff, yoff;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
659
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
660 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
661 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
662
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
663 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
664 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
665 bit = line->bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
666 drawable = GTK_LAYOUT (imhtml)->bin_window;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
667 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
668 gc = gdk_gc_new (drawable);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
669
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
670 if (bit->bg != NULL) {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
671 gdk_color_alloc (cmap, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
672 gdk_gc_set_foreground (gc, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
673
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
674 gdk_draw_rectangle (drawable, gc, TRUE, line->x - xoff, line->y - yoff,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
675 line->width, line->height);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
676 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
677
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
678 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
679 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
680
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
681 line_height = line->height / 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
682
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
683 gdk_draw_rectangle (drawable, gc, TRUE, line->x - xoff, line->y - yoff + line_height / 2,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
684 line->width, line_height);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
685
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
686 gdk_gc_unref (gc);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
687 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
688
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
689 static void
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
690 gtk_imhtml_draw_focus (GtkWidget *widget)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
691 {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
692 GtkIMHtml *imhtml;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
693 gint x = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
694 y = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
695 w = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
696 h = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
697
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
698 imhtml = GTK_IMHTML (widget);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
699
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
700 if (!GTK_WIDGET_DRAWABLE (widget))
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
701 return;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
702
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
703 if (GTK_WIDGET_HAS_FOCUS (widget)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
704 gtk_paint_focus (widget->style, widget->window, NULL, widget, "text", 0, 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
705 widget->allocation.width - 1, widget->allocation.height - 1);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
706 x = 1; y = 1; w = 2; h = 2;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
707 }
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
708
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
709 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
710 GTK_SHADOW_IN, NULL, widget, "text", x, y,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
711 widget->allocation.width - w, widget->allocation.height - h);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
712 }
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
713
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
714 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
715 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
716 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
717 GList *bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
718 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
719 GList *chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
720 struct line_info *line;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
721 gfloat x, y;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
722 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
723 guint32 width, height;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
724 #else
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2022
diff changeset
725 gint width, height;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
726 #endif
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
727
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
728 x = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
729 y = GTK_LAYOUT (imhtml)->vadjustment->value;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
730 gdk_window_get_size (GTK_LAYOUT (imhtml)->bin_window, &width, &height);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
731
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
732 bits = imhtml->bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
733
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
734 while (bits) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
735 bit = bits->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
736 chunks = bit->chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
737 if (DRAW_IMG (bit)) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
738 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
739 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
740 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
741 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
742 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
743 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
744 draw_img (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
745 }
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
746 } else if (bit->type == TYPE_SEP) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
747 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
748 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
749 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
750 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
751 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
752 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
753 draw_line (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
754
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
755 line = chunks->next->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
756 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
757 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
758 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
759 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
760 draw_text (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
761 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
762 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
763 while (chunks) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
764 line = chunks->data;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
765 if ((line->x <= x + width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
766 (line->y <= y + height) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
767 (x <= line->x + line->width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
768 (y <= line->y + line->height))
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
769 draw_text (imhtml, line);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
770 chunks = g_list_next (chunks);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
771 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
772 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
773 bits = g_list_next (bits);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
774 }
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
775
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
776 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
779 #if !GTK_CHECK_VERSION(1,3,0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 gtk_imhtml_draw (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 GdkRectangle *area)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
784 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
785
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
786 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
787 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 }
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
789 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 gtk_imhtml_style_set (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793 GtkStyle *style)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
796
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798 g_return_if_fail (GTK_IS_IMHTML (widget));
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
799
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
800 if (GTK_WIDGET_CLASS (parent_class)->style_set)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
801 (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, style);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
802
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 if (!GTK_WIDGET_REALIZED (widget))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 imhtml = GTK_IMHTML (widget);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
807 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810 static gint
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
811 gtk_imhtml_expose_event (GtkWidget *widget,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
812 GdkEventExpose *event)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
814 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
815
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
816 g_return_val_if_fail (widget != NULL, FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
817 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
818
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
819 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
820 gtk_imhtml_draw_exposed (imhtml);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
821
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
822 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 gtk_imhtml_redraw_all (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 GList *b;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831 gfloat oldvalue;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
832 gint oldy;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 oldvalue = vadj->value / vadj->upper;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
836 oldy = imhtml->y;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
838 gtk_layout_freeze (GTK_LAYOUT (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
848 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
849 imhtml->y = TOP_BORDER;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852
2002
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
853 if (GTK_LAYOUT (imhtml)->yoffset < TOP_BORDER)
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
854 gdk_window_clear_area (GTK_LAYOUT (imhtml)->bin_window, 0, 0,
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
855 imhtml->xsize, TOP_BORDER - GTK_LAYOUT (imhtml)->yoffset);
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
856
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 b = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 while (b) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
859 bit = b->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 b = g_list_next (b);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
861 while (bit->chunks) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
862 struct line_info *li = bit->chunks->data;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
863 if (li->text)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
864 g_free (li->text);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
865 bit->chunks = g_list_remove (bit->chunks, li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
866 g_free (li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
867 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
868 gtk_imhtml_draw_bit (imhtml, bit);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
871 GTK_LAYOUT (imhtml)->height = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
872 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
873 gtk_signal_emit_by_name (GTK_OBJECT (GTK_LAYOUT (imhtml)->vadjustment), "changed");
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
874
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
875 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 gtk_adjustment_set_value (vadj, vadj->upper * oldvalue);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
877
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
878 if (GTK_LAYOUT (imhtml)->bin_window && (imhtml->y < oldy)) {
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
879 GdkGC *gc;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
880 GdkColormap *cmap;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
881
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
882 gc = gdk_gc_new (GTK_LAYOUT (imhtml)->bin_window);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
883 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
884
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
885 gdk_color_alloc (cmap, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
886 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
887
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
888 gdk_draw_rectangle (GTK_LAYOUT (imhtml)->bin_window, gc, TRUE,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
889 0, imhtml->y - GTK_LAYOUT (imhtml)->vadjustment->value,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
890 GTK_WIDGET (imhtml)->allocation.width,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
891 oldy - imhtml->y);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
892
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
893 gdk_gc_unref (gc);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
894 }
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
895
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
896 gtk_layout_thaw (GTK_LAYOUT (imhtml));
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
897 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 gtk_imhtml_size_allocate (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 GtkAllocation *allocation)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 GtkIMHtml *imhtml;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
905 GtkLayout *layout;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
906 gint new_xsize, new_ysize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 g_return_if_fail (allocation != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
912 imhtml = GTK_IMHTML (widget);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
913 layout = GTK_LAYOUT (widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
914
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
915 widget->allocation = *allocation;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
916
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
917 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
918 new_xsize = MAX (1, (gint) allocation->width -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
919 (gint) (widget->style->xthickness + BORDER_SIZE) * 2);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
920 new_ysize = MAX (1, (gint) allocation->height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
921 (gint) (widget->style->ythickness + BORDER_SIZE) * 2);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
922
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
923 if (GTK_WIDGET_REALIZED (widget)) {
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
924 gint x = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
925 gint y = widget->style->ythickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
926 gdk_window_move_resize (widget->window,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
927 allocation->x, allocation->y,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
928 allocation->width, allocation->height);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
929 gdk_window_move_resize (layout->bin_window,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
930 x, y, new_xsize, new_ysize);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
931 }
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
932 #else
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
933 new_xsize = MAX (1, (gint) allocation->width -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
934 (gint) (widget->style->klass->xthickness + BORDER_SIZE) * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
935 new_ysize = MAX (1, (gint) allocation->height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
936 (gint) (widget->style->klass->ythickness + BORDER_SIZE) * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
937
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
938 if (GTK_WIDGET_REALIZED (widget)) {
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
939 gint x = widget->style->klass->xthickness + BORDER_SIZE;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
940 gint y = widget->style->klass->ythickness + BORDER_SIZE;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
941 gdk_window_move_resize (widget->window,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
942 allocation->x, allocation->y,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
943 allocation->width, allocation->height);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
944 gdk_window_move_resize (layout->bin_window,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
945 x, y, new_xsize, new_ysize);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
946 }
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
947 #endif
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
948
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
949 layout->hadjustment->page_size = new_xsize;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
950 layout->hadjustment->page_increment = new_xsize / 2;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
951 layout->hadjustment->lower = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
952 layout->hadjustment->upper = imhtml->x;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
953
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
954 layout->vadjustment->page_size = new_ysize;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
955 layout->vadjustment->page_increment = new_ysize / 2;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
956 layout->vadjustment->lower = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
957 layout->vadjustment->upper = imhtml->y;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
958
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
959 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
960 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
962 if (new_xsize == imhtml->xsize) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
963 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y - new_ysize)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
964 if (imhtml->y > new_ysize)
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
965 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
966 imhtml->y - new_ysize);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
967 else
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
968 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, 0);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
969 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 return;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
971 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
973 imhtml->xsize = new_xsize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
975 if (GTK_WIDGET_REALIZED (widget))
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
976 gtk_imhtml_redraw_all (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 }
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 gtk_imhtml_select_none (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 struct line_info *chunk;
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 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
995 chunk = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
996
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
997 if (chunk->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
998 chunk->selected = FALSE;
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
999 chunk->sel_start = chunk->text;
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1000 chunk->sel_end = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1001 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1002 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1003 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1004 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1005 else if (chunk->width)
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1006 draw_text (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1007 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 }
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1014 imhtml->sel_endchunk = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 static gchar*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018 get_position (struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 gint x,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022 gint width = x - chunk->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 gchar *pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 guint total = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1027 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 if (smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043 if (width <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044 return text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1046 for (pos = text; *pos != '\0'; pos++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1047 gint char_width = gdk_text_width (chunk->bit->font, pos, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048 if ((width > total) && (width <= total + char_width)) {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1049 if (width < total + (char_width / 2))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 return ++pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 total += char_width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 static GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 append_to_sel (GString *string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 GString *new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 gchar *buf;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 gchar *start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1073 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1074 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1076 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1077 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 if (smileys) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081 start = (chunk->sel_start == NULL) ? chunk->bit->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1087 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 case TYPE_BR:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095 buf = g_strdup ("\n");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1100 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1101
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102 new_string = g_string_append (string, buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 g_free (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 return new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 #define COORDS_IN_CHUNK(xx, yy) (((xx) < chunk->x + chunk->width) && \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 ((yy) < chunk->y + chunk->height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 gtk_imhtml_select_bits (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1113 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 guint startx = imhtml->sel_startx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 starty = imhtml->sel_starty,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 endx = imhtml->sel_endx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 endy = imhtml->sel_endy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123 gchar *new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 gint selection = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1125 gboolean smileys = imhtml->smileys;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126 gboolean redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 gboolean got_start = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 gboolean got_end = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 if (!imhtml->selection)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1133 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 if (imhtml->selected_text) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1138 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1140 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1142 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1143 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1146 chunk = chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148 switch (selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 case 0:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 if (COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 if (COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164 if (got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 if (chunk->sel_end != new_pos)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 if (chunk->sel_start > new_pos) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 chunk->sel_end = chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 selection = 2;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1174 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1186 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 } else if (!COORDS_IN_CHUNK (startx, starty) && !got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 if (chunk->selected)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199 if (!got_start && COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 } else if (!got_end && COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1220 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 if ( !chunk->selected ||
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1224 (chunk->sel_end != NULL) ||
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1225 (chunk->sel_start != chunk->text))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 case 2:
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1234 if (chunk->selected)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 if (chunk->selected == TRUE)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 imhtml->selected_text = append_to_sel (imhtml->selected_text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244 chunk, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1245
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 if (redraw) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1247 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1248 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1249 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1250 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1251 else if (chunk->width)
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1252 draw_text (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1263 static void
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1264 gtk_imhtml_select_in_chunk (GtkIMHtml *imhtml,
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1265 struct line_info *chunk)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1266 {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1267 GtkIMHtmlBit *bit = chunk->bit;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1268 gchar *new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1269 guint endx = imhtml->sel_endx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1270 guint startx = imhtml->sel_startx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1271 guint starty = imhtml->sel_starty;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1272 gboolean smileys = imhtml->smileys;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1273 gboolean redraw = FALSE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1274
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1275 new_pos = get_position (chunk, endx, smileys);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1276 if ((starty < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1277 ((starty < chunk->y + chunk->height) && (startx < endx))) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1278 if (chunk->sel_end != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1279 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1280 chunk->sel_end = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1281 } else {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1282 if (chunk->sel_start != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1283 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1284 chunk->sel_start = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1285 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1286
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1287 if (redraw) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1288 if (DRAW_IMG (bit))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1289 draw_img (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1290 else if ((bit->type == TYPE_SEP) &&
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1291 (bit->chunks->data == chunk))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1292 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1293 else if (chunk->width)
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1294 draw_text (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1295 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1296 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1297
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 scroll_timeout (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 GdkEventMotion event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303 GdkModifierType mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1304
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1307 gdk_window_get_pointer (GTK_LAYOUT (imhtml)->bin_window, &x, &y, &mask);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 if (mask & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 event.is_hint = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 event.x = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312 event.y = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313 event.state = mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 gtk_imhtml_motion_notify_event (GTK_WIDGET (imhtml), &event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1316 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1317
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 static gint
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1322 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1323 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1324 GtkStyle *style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1325 GdkFont *font;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1326 gint y, baseline_skip, gap;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1327
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1328 style = imhtml->tip_window->style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1329 font = GTK_IMHTML_GET_STYLE_FONT (style);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1330
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1331 gap = (font->ascent + font->descent) / 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1332 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1333 gap = 2;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1334 baseline_skip = font->ascent + font->descent + gap;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1335
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1336 if (!imhtml->tip_bit)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1337 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1338
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1339 gtk_paint_flat_box (style, imhtml->tip_window->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1340 NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1341
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1342 y = font->ascent + 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1343 gtk_paint_string (style, imhtml->tip_window->window, GTK_STATE_NORMAL, NULL,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1344 imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->url);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1345
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1346 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1347 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1348
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1349 static gint
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1350 gtk_imhtml_tip (gpointer data)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1351 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1352 GtkIMHtml *imhtml = data;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1353 GtkWidget *widget = GTK_WIDGET (imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1354 GtkStyle *style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1355 GdkFont *font;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1356 gint gap, x, y, w, h, scr_w, scr_h, baseline_skip;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1357
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1358 if (!imhtml->tip_bit || !GTK_WIDGET_DRAWABLE (widget)) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1359 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1360 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1361 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1362
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1363 if (imhtml->tip_window)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1364 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1365
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1366 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1367 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1368 gtk_window_set_policy (GTK_WINDOW (imhtml->tip_window), FALSE, FALSE, TRUE);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1369 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips");
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1370 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "expose_event",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1371 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1372 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "draw",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1373 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1374
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1375 gtk_widget_ensure_style (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1376 style = imhtml->tip_window->style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1377 font = GTK_IMHTML_GET_STYLE_FONT (style);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1378
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1379 scr_w = gdk_screen_width ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1380 scr_h = gdk_screen_height ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1381
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1382 gap = (font->ascent + font->descent) / 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1383 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1384 gap = 2;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1385 baseline_skip = font->ascent + font->descent + gap;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1386
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1387 w = 8 + gdk_string_width (font, imhtml->tip_bit->url);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1388 h = 8 - gap + baseline_skip;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1389
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1390 gdk_window_get_pointer (NULL, &x, &y, NULL);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1391 if (GTK_WIDGET_NO_WINDOW (widget))
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1392 y += widget->allocation.y;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1393
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1394 x -= ((w >> 1) + 4);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1395
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1396 if ((x + w) > scr_w)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1397 x -= (x + w) - scr_w;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1398 else if (x < 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1399 x = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1400
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1401 if ((y + h + + 4) > scr_h)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1402 y = y - imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent;
2071
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1403 else
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1404 if (imhtml->tip_bit->font)
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1405 y = y + imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent;
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1406 else
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1407 y = y + font->ascent + font->descent;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1408
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1409 gtk_widget_set_usize (imhtml->tip_window, w, h);
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1410 gtk_widget_set_uposition (imhtml->tip_window, x, y);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1411 gtk_widget_show (imhtml->tip_window);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1412
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1413 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1414 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1415 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1416
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1417 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 gtk_imhtml_motion_notify_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419 GdkEventMotion *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422 GdkModifierType state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1427 if (event->is_hint)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 gdk_window_get_pointer (event->window, &x, &y, &state);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432 state = event->state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 if (state & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 gint height = vadj->page_size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1438 gint yy = y - vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440 if (((yy < 0) || (yy > height)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1441 (imhtml->scroll_timer == 0) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1442 (vadj->upper > vadj->page_size)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 imhtml->scroll_timer = gtk_timeout_add (100,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 (GtkFunction) scroll_timeout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 imhtml);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1446 diff = (yy < 0) ? (yy / 2) : ((yy - height) / 2);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 gtk_adjustment_set_value (vadj,
2337
e3939d21c2f0 [gaim-migrate @ 2350]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2188
diff changeset
1448 MIN (vadj->value + diff, vadj->upper - height));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 if (imhtml->selection) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1452 struct line_info *chunk = imhtml->sel_endchunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454 imhtml->sel_endy = MAX (y, 0);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1455 if ((chunk == NULL) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1456 (x < chunk->x) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1457 (x > chunk->x + chunk->width) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1458 (y < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1459 (y > chunk->y + chunk->height))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1460 gtk_imhtml_select_bits (imhtml);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1461 else
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1462 gtk_imhtml_select_in_chunk (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1463 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1464 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 GList *urls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 while (urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 uw = (struct url_widget *) urls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 if ((x > uw->x) && (x < uw->x + uw->width) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1472 if (imhtml->tip_bit != uw->bit) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1473 imhtml->tip_bit = uw->bit;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1474 if (imhtml->tip_timer != 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1475 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1476 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1477 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1478 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1479 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1480 imhtml->tip_timer = gtk_timeout_add (TOOLTIP_TIMEOUT,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1481 gtk_imhtml_tip,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1482 imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1483 }
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1484 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window,
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1485 imhtml->hand_cursor);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1486 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1487 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1488 urls = g_list_next (urls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1490 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1492 if (imhtml->tip_timer) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1493 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1494 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1495 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1496 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1497 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1498 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1499 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1500 imhtml->tip_bit = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1501
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1502 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1504 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1505 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1506
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1507 static gint
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1508 gtk_imhtml_leave_notify_event (GtkWidget *widget,
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1509 GdkEventCrossing *event)
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1510 {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1511 GtkIMHtml *imhtml = GTK_IMHTML (widget);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1512
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1513 if (imhtml->tip_timer) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1514 gtk_timeout_remove (imhtml->tip_timer);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1515 imhtml->tip_timer = 0;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1516 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1517 if (imhtml->tip_window) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1518 gtk_widget_destroy (imhtml->tip_window);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1519 imhtml->tip_window = NULL;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1520 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1521 imhtml->tip_bit = NULL;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1522
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1523 return TRUE;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1524 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1525
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1526 static void
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1527 menu_open_url (GtkObject *object,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1528 gpointer data)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1529 {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1530 struct url_widget *uw = data;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1531
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1532 gtk_signal_emit (GTK_OBJECT (uw->imhtml), signals [URL_CLICKED], uw->bit->url);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1533 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1534
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1535 static void
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1536 menu_copy_link (GtkObject *object,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1537 gpointer data)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1538 {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1539 struct url_widget *uw = data;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1540 GtkIMHtml *imhtml = uw->imhtml;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1541
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1542 if (imhtml->selected_text)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1543 g_string_free (imhtml->selected_text, TRUE);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1544
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1545 gtk_imhtml_select_none (uw->imhtml);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1546
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1547 imhtml->selection = TRUE;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1548 imhtml->selected_text = g_string_new (uw->bit->url);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1549
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1550 gtk_selection_owner_set (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1551 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1552
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1553 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1554 gtk_imhtml_button_press_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1556 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1557 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1558 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1559 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1560 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1561
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1562 x = event->x + hadj->value;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1563 y = event->y + vadj->value;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1564
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1565 if (event->button == 1) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1566 imhtml->sel_startx = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1567 imhtml->sel_starty = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1568 imhtml->selection = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1569 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1570 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1571
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1572 if (event->button == 3) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1573 GList *urls = imhtml->urls;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1574 struct url_widget *uw;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1575
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1576 while (urls) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1577 uw = urls->data;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1578 if ((x > uw->x) && (x < uw->x + uw->width) &&
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1579 (y > uw->y) && (y < uw->y + uw->height)) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1580 GtkWidget *menu = gtk_menu_new ();
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1581
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1582 GtkWidget *button = gtk_menu_item_new_with_label ("Open URL");
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1583 gtk_signal_connect (GTK_OBJECT (button), "activate",
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1584 GTK_SIGNAL_FUNC (menu_open_url), uw);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1585 gtk_menu_append (GTK_MENU (menu), button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1586 gtk_widget_show (button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1587
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1588 button = gtk_menu_item_new_with_label ("Copy Link Location");
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1589 gtk_signal_connect (GTK_OBJECT (button), "activate",
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1590 GTK_SIGNAL_FUNC (menu_copy_link), uw);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1591 gtk_menu_append (GTK_MENU (menu), button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1592 gtk_widget_show (button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1593
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1594 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1595 3, event->time);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1596
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1597 if (imhtml->tip_timer) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1598 gtk_timeout_remove (imhtml->tip_timer);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1599 imhtml->tip_timer = 0;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1600 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1601 if (imhtml->tip_window) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1602 gtk_widget_destroy (imhtml->tip_window);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1603 imhtml->tip_window = NULL;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1604 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1605 imhtml->tip_bit = NULL;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1606
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1607 return TRUE;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1608 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1609 urls = g_list_next (urls);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1610 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1611 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1612
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1613 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1614 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 gtk_imhtml_button_release_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1624
1456
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1625 x = event->x + hadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1626 y = event->y + vadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1627
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628 if ((event->button == 1) && imhtml->selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1629 if ((x == imhtml->sel_startx) && (y == imhtml->sel_starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1630 imhtml->sel_startx = imhtml->sel_starty = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1631 imhtml->selection = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1632 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1633 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1634 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1635 imhtml->sel_endy = MAX (y, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1636 gtk_imhtml_select_bits (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1637 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1638
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1639 gtk_selection_owner_set (widget, GDK_SELECTION_PRIMARY, event->time);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1640 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1641
1547
7b50a08090a2 [gaim-migrate @ 1557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1528
diff changeset
1642 if ((event->button == 1) && (imhtml->sel_startx == 0)) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1643 GList *urls = imhtml->urls;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1644 struct url_widget *uw;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1645
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1646 while (urls) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1647 uw = (struct url_widget *) urls->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1648 if ((x > uw->x) && (x < uw->x + uw->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1649 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1650 gtk_signal_emit (GTK_OBJECT (imhtml), signals [URL_CLICKED],
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1651 uw->bit->url);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1652 return TRUE;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1653 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1654 urls = g_list_next (urls);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1655 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1656 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1657
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1658 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1659 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1660
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1661 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1662 gtk_imhtml_selection_get (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1663 GtkSelectionData *sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1664 guint sel_info,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1665 guint32 time)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1666 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1667 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1668 gchar *string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1669 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1670
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1671 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1672 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1673 g_return_if_fail (sel_data->selection == GDK_SELECTION_PRIMARY);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1675 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1676
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1677 g_return_if_fail (imhtml->selected_text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1678 g_return_if_fail (imhtml->selected_text->str != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1679
2188
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1680 if (imhtml->selected_text->len <= 0)
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1681 return;
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1682
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1683 string = g_strdup (imhtml->selected_text->str);
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1684 length = strlen (string);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1685
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1686 if (sel_info == TARGET_STRING) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1687 gtk_selection_data_set (sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688 GDK_SELECTION_TYPE_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 8 * sizeof (gchar),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690 (guchar *) string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1691 length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692 } else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 guchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694 GdkAtom encoding;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1695 gint format;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 gint new_length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698 gdk_string_to_compound_text (string, &encoding, &format, &text, &new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699 gtk_selection_data_set (sel_data, encoding, format, text, new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1700 gdk_free_compound_text (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702
2188
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1703 g_free (string);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1704 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1705
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1706 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1707 gtk_imhtml_selection_clear_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1708 GdkEventSelection *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1710 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1711
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 g_return_val_if_fail (widget != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714 g_return_val_if_fail (event != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1715 g_return_val_if_fail (event->selection == GDK_SELECTION_PRIMARY, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1716
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1717 if (!gtk_selection_clear (widget, event))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1721
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1722 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1725 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1726
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1727 static void
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1728 gtk_imhtml_adjustment_changed (GtkAdjustment *adjustment,
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1729 GtkIMHtml *imhtml)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1730 {
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1731 GtkLayout *layout = GTK_LAYOUT (imhtml);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1732
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1733 layout->xoffset = (gint) layout->hadjustment->value;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1734 layout->yoffset = (gint) layout->vadjustment->value;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1735
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1736 if (!GTK_WIDGET_MAPPED (imhtml) || !GTK_WIDGET_REALIZED (imhtml))
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1737 return;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1738
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1739 if (layout->freeze_count)
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1740 return;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1741
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1742 if (layout->yoffset < TOP_BORDER)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1743 gdk_window_clear_area (layout->bin_window, 0, 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1744 imhtml->xsize, TOP_BORDER - layout->yoffset);
1961
0a3edeba05b6 [gaim-migrate @ 1971]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1955
diff changeset
1745
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1746 gtk_imhtml_draw_exposed (imhtml);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1747 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1748
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1749 static void
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750 gtk_imhtml_set_scroll_adjustments (GtkLayout *layout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1751 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1752 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 {
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1754 gboolean need_adjust = FALSE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1755
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1756 g_return_if_fail (layout != NULL);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1757 g_return_if_fail (GTK_IS_IMHTML (layout));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1758
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1759 if (hadj)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1760 g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1761 else
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1762 hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1763 if (vadj)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1764 g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1765 else
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1766 vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1767
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1768 if (layout->hadjustment && (layout->hadjustment != hadj)) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1769 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->hadjustment), layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1770 gtk_object_unref (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1771 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1772
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1773 if (layout->vadjustment && (layout->vadjustment != vadj)) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1774 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->vadjustment), layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1775 gtk_object_unref (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1776 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1777
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1778 if (layout->hadjustment != hadj) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1779 layout->hadjustment = hadj;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1780 gtk_object_ref (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1781 gtk_object_sink (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1782
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1783 gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed",
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1784 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1785 need_adjust = TRUE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1786 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1787
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1788 if (layout->vadjustment != vadj) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1789 layout->vadjustment = vadj;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1790 gtk_object_ref (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1791 gtk_object_sink (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1792
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1793 gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed",
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1794 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1795 need_adjust = TRUE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1796 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1797
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1798 if (need_adjust)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1799 gtk_imhtml_adjustment_changed (NULL, GTK_IMHTML (layout));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1800 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1801
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803 gtk_imhtml_class_init (GtkIMHtmlClass *class)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 {
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1805 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1806 GObjectClass *gobject_class;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1807 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 GtkObjectClass *object_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809 GtkWidgetClass *widget_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1810 GtkLayoutClass *layout_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1812 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1813 gobject_class = (GObjectClass*) class;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1814 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 object_class = (GtkObjectClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1816 widget_class = (GtkWidgetClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1817 layout_class = (GtkLayoutClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1818
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1819 parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1820
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1821 signals [URL_CLICKED] =
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822 gtk_signal_new ("url_clicked",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1823 GTK_RUN_FIRST,
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1824 GTK_CLASS_TYPE (object_class),
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1825 GTK_SIGNAL_OFFSET (GtkIMHtmlClass, url_clicked),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1826 gtk_marshal_NONE__POINTER,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1827 GTK_TYPE_NONE, 1,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1828 GTK_TYPE_POINTER);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1829
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1830 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1831 gobject_class->finalize = gtk_imhtml_finalize;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1832 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835 object_class->destroy = gtk_imhtml_destroy;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1836 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1837
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1838 widget_class->realize = gtk_imhtml_realize;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1839 #if !GTK_CHECK_VERSION(1,3,0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840 widget_class->draw = gtk_imhtml_draw;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1841 widget_class->draw_focus = gtk_imhtml_draw_focus;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1842 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1843 widget_class->style_set = gtk_imhtml_style_set;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1844 widget_class->expose_event = gtk_imhtml_expose_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1845 widget_class->size_allocate = gtk_imhtml_size_allocate;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1846 widget_class->motion_notify_event = gtk_imhtml_motion_notify_event;
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1847 widget_class->leave_notify_event = gtk_imhtml_leave_notify_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1848 widget_class->button_press_event = gtk_imhtml_button_press_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1849 widget_class->button_release_event = gtk_imhtml_button_release_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1850 widget_class->selection_get = gtk_imhtml_selection_get;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1851 widget_class->selection_clear_event = gtk_imhtml_selection_clear_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1852
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1853 layout_class->set_scroll_adjustments = gtk_imhtml_set_scroll_adjustments;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1854 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1855
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1856 static gchar**
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1857 get_font_names ()
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1858 {
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1859 gint num_fonts = 0;
2065
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1860 gchar **xfontnames;
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1861 static gchar **fonts = NULL;
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1862 gint i;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1863
2065
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1864 if (fonts)
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1865 return fonts;
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1866
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1867 xfontnames = XListFonts (GDK_DISPLAY (), "-*", MAX_FONTS, &num_fonts);
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1868
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1869 if (!num_fonts) {
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1870 XFreeFontNames(xfontnames);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1871 return g_new0 (char *, 1);
2065
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1872 }
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1873
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1874 fonts = g_new0 (char *, num_fonts + 1);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1875
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1876 for (i = 0; i < num_fonts; i++) {
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1877 gint countdown = 1, num_dashes = 1;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1878 const gchar *t1 = xfontnames [i];
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1879 const gchar *t2;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1880
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1881 while (*t1 && (countdown >= 0))
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1882 if (*t1++ == '-')
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1883 countdown--;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1884
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1885 for (t2 = t1; *t2; t2++)
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1886 if (*t2 == '-' && --num_dashes == 0)
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1887 break;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1888
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1889 fonts [i] = g_strndup (t1, (long) t2 - (long) t1);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1890 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1891
2065
391440022697 [gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
1892 XFreeFontNames(xfontnames);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1893 return fonts;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1894 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1895
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1896 static GdkFont*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897 gtk_imhtml_font_load (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1898 gchar *name,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1899 gboolean bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1900 gboolean italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1901 gint fontsize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1902 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1903 gchar buf [16 * 1024];
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1904 GdkFont *font = NULL;
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
1905 XFontStruct *xfs;
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1906 static gchar **fontnames = NULL;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1907 gchar *choice = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1908 gint size = fontsize ? font_sizes [MIN (fontsize, MAX_SIZE) - 1] : 120;
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1909 gint i, j;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1910
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1911 if (!fontnames)
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1912 fontnames = get_font_names ();
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1913
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1914 if (name) {
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1915 gchar **choices = g_strsplit (name, ",", -1);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1916
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1917 for (i = 0; choices [i]; i++) {
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1918 for (j = 0; fontnames [j]; j++)
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2022
diff changeset
1919 if (!g_strcasecmp (fontnames [j], choices [i]))
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1920 break;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1921 if (fontnames [j])
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1922 break;
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1923 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1924
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1925 if (choices [i])
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1926 choice = g_strdup (choices [i]);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1927
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1928 g_strfreev (choices);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1929 } else if (!bold && !italics && !fontsize && imhtml->default_font)
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1930 return gdk_font_ref (imhtml->default_font);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1931
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1932 if (!choice) {
2615
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1933 for (i = 0; fontnames [i]; i++)
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1934 if (!g_strcasecmp (fontnames [i], DEFAULT_FONT_NAME))
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1935 break;
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1936 if (fontnames [i])
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1937 choice = g_strdup (DEFAULT_FONT_NAME);
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1938 }
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1939
8b84198651c9 [gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2610
diff changeset
1940 if (!choice) {
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1941 if (imhtml->default_font)
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1942 return gdk_font_ref (imhtml->default_font);
2115
3ce77b547cf2 [gaim-migrate @ 2125]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2075
diff changeset
1943 return gdk_fontset_load ("-*-*-*-*-*-*-*-*-*-*-*-*-*-*,*");
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1944 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1945
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1946 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-%s",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1947 choice,
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948 bold ? "bold" : "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949 italics ? 'i' : 'r',
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1950 size,
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1951 getcharset());
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
1952 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1953
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1954 if (!font && italics) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1955 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-%d-*-*-*-*-%s",
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1956 choice,
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1957 bold ? "bold" : "medium",
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1958 size,
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1959 getcharset());
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1960 font = gdk_font_load (buf);
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1961 }
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1962
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1963 if (!font) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1964 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-*-*-*-*-*-%s",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1965 choice,
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966 bold ? "bold" : "medium",
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1967 italics ? 'i' : 'r',
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1968 getcharset());
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
1969 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1970 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1971
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1972 if (!font && italics) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1973 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-*-*-*-*-*-%s",
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1974 choice,
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1975 bold ? "bold" : "medium",
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1976 getcharset());
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1977 font = gdk_font_load (buf);
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1978 }
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
1979
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1980 if (!font) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1981 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-%s",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1982 choice,
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1983 italics ? 'i' : 'r',
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1984 getcharset());
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
1985 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1986 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1987
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1988 if (!font) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1989 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-%s",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1990 choice,
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1991 italics ? 'o' : '*',
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1992 getcharset());
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
1993 font = gdk_font_load (buf);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1995
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1996 if (!font && italics) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1997 g_snprintf (buf, sizeof (buf), "-*-%s-*-*-*-*-*-*-*-*-*-*-%s",
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1998 choice,
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
1999 getcharset());
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2000 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2001 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2002
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2003 if (!font) {
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2004 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2005 choice,
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2006 bold ? "bold" : "medium",
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 italics ? 'i' : 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008 size);
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2009 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2010 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2011
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2012 if (!font && italics) {
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2013 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-%d-*-*-*-*-*-*",
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2014 choice,
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2015 bold ? "bold" : "medium",
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2016 size);
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2017 font = gdk_font_load (buf);
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2018 }
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2019
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2020 if (!font) {
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2021 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-*-*-*-*-*-*-*",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2022 choice,
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2023 bold ? "bold" : "medium",
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2024 italics ? 'i' : 'r');
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2025 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2026 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2027
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2028 if (!font) {
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2029 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-*-*-*-*-*-*-*",
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2030 choice,
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2031 bold ? "bold" : "medium");
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2032 font = gdk_font_load (buf);
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2033 }
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2034
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
2035 if (!font) {
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2036 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-*-*",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2037 choice,
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2038 italics ? 'i' : 'r');
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2039 font = gdk_font_load (buf);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2040 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2041
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2042 if (!font) {
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2043 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-*-*",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2044 choice,
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2045 italics ? 'o' : '*');
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2046 font = gdk_font_load (buf);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2047 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2048
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2049 if (!font && italics) {
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2050 g_snprintf (buf, sizeof (buf), "-*-%s-*-*-*-*-*-*-*-*-*-*-*-*",
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2051 choice);
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2052 font = gdk_font_load (buf);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2053 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2054
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2055 g_free (choice);
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2056
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2057 if (!font && imhtml->default_font)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058 return gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2060 xfs = font ? GDK_FONT_XFONT (font) : NULL;
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2061 if (xfs && (xfs->min_byte1 != 0 || xfs->max_byte1 != 0)) {
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2062 gchar *tmp_name;
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2063
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2064 gdk_font_unref (font);
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2065 tmp_name = g_strconcat (buf, ",*", NULL);
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2066 font = gdk_fontset_load (tmp_name);
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2067 g_free (tmp_name);
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2068 }
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2069
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2070 if (!font)
2116
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2071 return gdk_fontset_load ("-*-*-*-*-*-*-*-*-*-*-*-*-*-*,*");
6402958c64c9 [gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2115
diff changeset
2072
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2073
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2074 return font;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2075 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2076
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2077 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2078 gtk_imhtml_init (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2079 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2080 static const GtkTargetEntry targets [] = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2081 { "STRING", 0, TARGET_STRING },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2082 { "TEXT", 0, TARGET_TEXT },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2083 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2084 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2085
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2086 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2087 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2088
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2089 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2090 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2091 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2092
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2093 GtkType
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2094 gtk_imhtml_get_type (void)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2095 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2096 static GtkType imhtml_type = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2097
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2098 if (!imhtml_type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2099 static const GtkTypeInfo imhtml_info = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2100 "GtkIMHtml",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2101 sizeof (GtkIMHtml),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2102 sizeof (GtkIMHtmlClass),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2103 (GtkClassInitFunc) gtk_imhtml_class_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2104 (GtkObjectInitFunc) gtk_imhtml_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2105 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2106 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2107 NULL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2108 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2109
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2110 imhtml_type = gtk_type_unique (GTK_TYPE_LAYOUT, &imhtml_info);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2111 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2112
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2113 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2114 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2115
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2116 static void
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2117 gtk_imhtml_init_smileys (GtkIMHtml *imhtml)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2118 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2119 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2120 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2121
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2122 imhtml->smiley_data = gtk_smiley_tree_new ();
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2123
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2124 gtk_imhtml_associate_smiley (imhtml, ":)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2125 gtk_imhtml_associate_smiley (imhtml, ":-)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2126
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2127 gtk_imhtml_associate_smiley (imhtml, ":(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2128 gtk_imhtml_associate_smiley (imhtml, ":-(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2129
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2130 gtk_imhtml_associate_smiley (imhtml, ";)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2131 gtk_imhtml_associate_smiley (imhtml, ";-)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2132
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2133 gtk_imhtml_associate_smiley (imhtml, ":-p", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2134 gtk_imhtml_associate_smiley (imhtml, ":-P", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2135
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2136 gtk_imhtml_associate_smiley (imhtml, "=-O", scream_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2137 gtk_imhtml_associate_smiley (imhtml, ":-*", kiss_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2138 gtk_imhtml_associate_smiley (imhtml, ">:o", yell_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2139 gtk_imhtml_associate_smiley (imhtml, "8-)", smile8_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2140 gtk_imhtml_associate_smiley (imhtml, ":-$", moneymouth_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2141 gtk_imhtml_associate_smiley (imhtml, ":-!", burp_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2142 gtk_imhtml_associate_smiley (imhtml, ":-[", embarrassed_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2143 gtk_imhtml_associate_smiley (imhtml, ":'(", cry_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2144
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2145 gtk_imhtml_associate_smiley (imhtml, ":-/", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2146 gtk_imhtml_associate_smiley (imhtml, ":-\\", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2147
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2148 gtk_imhtml_associate_smiley (imhtml, ":-X", crossedlips_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2149 gtk_imhtml_associate_smiley (imhtml, ":-D", bigsmile_xpm);
2583
ce3df2c43f46 [gaim-migrate @ 2596]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2556
diff changeset
2150 gtk_imhtml_associate_smiley (imhtml, ":-d", bigsmile_xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2151 gtk_imhtml_associate_smiley (imhtml, "O:-)", angel_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2152 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2153
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2154 GtkWidget*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2155 gtk_imhtml_new (GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2156 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2157 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2158 GtkIMHtml *imhtml = gtk_type_new (GTK_TYPE_IMHTML);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2159
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2160 gtk_imhtml_set_adjustments (imhtml, hadj, vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2161
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2162 imhtml->bits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2163 imhtml->urls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2164
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2165 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2166 imhtml->y = TOP_BORDER;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2167 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2168 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2169 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2171 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2172 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2173
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2174 imhtml->img = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2175
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2176 imhtml->smileys = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2177 imhtml->comments = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2178
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2179 gtk_imhtml_init_smileys (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2180
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2181 return GTK_WIDGET (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2182 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2183
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2184 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2185 gtk_imhtml_set_adjustments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2186 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2187 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2188 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2189 gtk_layout_set_hadjustment (GTK_LAYOUT (imhtml), hadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2190 gtk_layout_set_vadjustment (GTK_LAYOUT (imhtml), vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2191 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2192
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2193 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2194 gtk_imhtml_set_defaults (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2195 GdkFont *font,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2196 GdkColor *fg_color,
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2197 GdkColor *bg_color)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2198 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2199 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2200 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2201
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2202 if (font) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2203 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2204 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2205 imhtml->default_font = gdk_font_ref (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2206 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 if (fg_color) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2209 if (imhtml->default_fg_color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 gdk_color_free (imhtml->default_fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2211 imhtml->default_fg_color = gdk_color_copy (fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2212 }
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2213
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2214 if (bg_color) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2215 if (imhtml->default_bg_color)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2216 gdk_color_free (imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2217 imhtml->default_bg_color = gdk_color_copy (bg_color);
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
2218 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, imhtml->default_bg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2219 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2221
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2222 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2223 gtk_imhtml_set_img_handler (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2224 GtkIMHtmlImage handler)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2225 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2226 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2227 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2228
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2229 imhtml->img = handler;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2230 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2232 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235 gchar **xpm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2237 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 g_return_if_fail (text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 if (xpm == NULL)
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2242 gtk_smiley_tree_remove (imhtml->smiley_data, text);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 else
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2244 gtk_smiley_tree_insert (imhtml->smiley_data, text, xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2245 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2246
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2248 new_line (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2250 GList *last = g_list_last (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2254 li = last->data;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2255 if (li->x + li->width != imhtml->xsize)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2256 li->width = imhtml->xsize - li->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2258
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 last = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2261 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2262 if (li->height < MIN_HEIGHT) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2263 while (last) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2264 gint diff;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2265 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266 diff = MIN_HEIGHT - li->height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2267 li->height = MIN_HEIGHT;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2268 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2269 last = g_list_next (last);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2270 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2271 imhtml->llheight = MIN_HEIGHT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2278 imhtml->x = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 imhtml->y += imhtml->llheight;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2280 imhtml->llheight = 0;
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2281 imhtml->llascent = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2283
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2284 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285 backwards_update (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2287 gint height,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 gint ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 GList *ls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2292 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295 if (height > imhtml->llheight) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 diff = height - imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298 ls = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 while (ls) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2300 li = ls->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 li->height += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303 li->ascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2304 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2305 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 ls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 while (ls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 uw = ls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2312 if (uw->y + diff > imhtml->y)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313 uw->y += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2317 imhtml->llheight = height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 imhtml->llascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2321 imhtml->llascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2324
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 add_text_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2328 gchar *text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2329 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2330 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2331 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2332 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2334 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335 width = gdk_string_width (bit->font, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2336 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 width = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2340 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2343 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2344 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2345 li->ascent = MAX (imhtml->llascent, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2346 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2348 li->text = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2350
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 if (bit->url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2352 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2354 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2355 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356 uw->height = imhtml->llheight;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
2357 uw->imhtml = imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
2358 uw->bit = bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2360 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2361
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2362 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2363 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2364 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2365
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2367 add_img_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2371 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2373
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 gdk_window_get_size (bit->pm, &width, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2377 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2378 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2383
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384 if (bit->url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2388 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2389 uw->height = imhtml->llheight;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
2390 uw->imhtml = imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
2391 uw->bit = bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2392 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2394
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2395 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2396 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2402 gtk_imhtml_draw_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2403 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2404 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405 gint width, height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2407 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2408 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 g_return_if_fail (bit != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2410
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 if ( (bit->type == TYPE_TEXT) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412 ((bit->type == TYPE_SMILEY) && !imhtml->smileys) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 ((bit->type == TYPE_COMMENT) && imhtml->comments)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2414 gchar *copy = g_strdup (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2415 gint pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416 gboolean seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 height = bit->font->ascent + bit->font->descent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 width = gdk_string_width (bit->font, bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2421
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2422 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2423 gint remain = imhtml->xsize - imhtml->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424 while (gdk_text_width (bit->font, copy, pos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425 if (copy [pos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2427 pos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2428 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429 if (seenspace) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 while (copy [pos - 1] != ' ') pos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 tmp = g_strndup (copy, pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437 pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2438 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2440 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2441
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2442 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2443
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2444 while (pos < strlen (bit->text)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2445 width = gdk_string_width (bit->font, copy + pos);
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2446 if (imhtml->x + width > imhtml->xsize) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2447 gint newpos = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2448 gint remain = imhtml->xsize - imhtml->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2449 while (gdk_text_width (bit->font, copy + pos, newpos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 if (copy [pos + newpos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2451 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 newpos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 if (seenspace)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456 while (copy [pos + newpos - 1] != ' ') newpos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2457
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2458 if (newpos == 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2459 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2460
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461 tmp = g_strndup (copy + pos, newpos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462 pos += newpos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2463
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2464 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2465 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2466
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2467 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2468 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2469 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2470 tmp = g_strdup (copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2471
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2472 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2475 pos = strlen (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2477 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2478 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2480
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2482 } else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2483 gdk_window_get_size (bit->pm, &width, &height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2484
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2485 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2486 new_line (imhtml);
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2487 else
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2488 backwards_update (imhtml, bit, height, 0);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2489
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2490 add_img_renderer (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 } else if (bit->type == TYPE_BR) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 } else if (bit->type == TYPE_SEP) {
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2495 struct line_info *li;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2496 if (imhtml->llheight)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 new_line (imhtml);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2498
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2499 li = g_new0 (struct line_info, 1);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2500 li->x = imhtml->x;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2501 li->y = imhtml->y;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2502 li->width = imhtml->xsize;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2503 li->height = HR_HEIGHT * 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2504 li->ascent = 0;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2505 li->text = NULL;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2506 li->bit = bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2507
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2508 bit->chunks = g_list_append (bit->chunks, li);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2509
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 imhtml->llheight = HR_HEIGHT * 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2513 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2514 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2517 gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2518 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2523 imhtml->smileys = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2525 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2526 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2527 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2528
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2529 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2530 gtk_imhtml_show_comments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2531 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2532 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2533 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2534 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2535
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2536 imhtml->comments = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2537
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2538 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2539 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2540 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2541
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2542 static GdkColor *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543 gtk_imhtml_get_color (const gchar *color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2544 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 GdkColor c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2546
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2547 if (!gdk_color_parse (color, &c))
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2548 return NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2549
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
2550 return gdk_color_copy (&c);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2551 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2552
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2553 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2554 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 const gchar *text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2556 {
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2557 return gtk_smiley_tree_lookup (imhtml->smiley_data, text);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2559
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2560 static GtkIMHtmlBit *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2561 gtk_imhtml_new_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2562 gint type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2563 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2564 gint bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2565 gint italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2566 gint underline,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2567 gint strike,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2568 FontDetail *font,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2569 GdkColor *bg,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2570 gchar *url,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2571 gint pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2572 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2573 GtkIMHtmlBit *bit = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2574
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2575 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2576 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2577
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2578 if ((type == TYPE_TEXT) && ((text == NULL) || (strlen (text) == 0)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2579 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2580
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2581 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2582 bit->type = type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2583
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2584 if ((text != NULL) && (strlen (text) != 0))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2585 bit->text = g_strdup (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2586
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2587 if ((font != NULL) || bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2588 if (font && (bold || italics || font->size || font->face || pre)) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2589 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2590 bit->font = gtk_imhtml_font_load (imhtml, "courier", bold, italics, font->size);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2591 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2592 bit->font = gtk_imhtml_font_load (imhtml, font->face, bold, italics, font->size);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2593 }
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2594 } else if (bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2595 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2596 bit->font = gtk_imhtml_font_load (imhtml, "Courier", bold, italics, 0);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2597 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2598 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2599 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2600 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2601
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2602 if (font && (type != TYPE_BR)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2603 if (font->fore != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2604 bit->fore = gdk_color_copy (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2605
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2606 if (font->back != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2607 bit->back = gdk_color_copy (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2608 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2609 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2610
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2611 if (((bit->type == TYPE_TEXT) || (bit->type == TYPE_SMILEY) || (bit->type == TYPE_COMMENT)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2612 (bit->font == NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2613 bit->font = gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2614
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2615 if (bg != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2616 bit->bg = gdk_color_copy (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2617
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2618 bit->underline = underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2619 bit->strike = strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2620
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2621 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2622 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2623
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2624 if (type == TYPE_SMILEY) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2625 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2626
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2627 if ((font != NULL) && (font->back != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2628 clr = font->back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2629 else
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2630 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2631
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2632 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2633 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2634 clr,
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2635 gtk_smiley_tree_image (imhtml->smiley_data, text));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2636 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2637
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2638 return bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2639 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2640
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2641 #define NEW_TEXT_BIT gtk_imhtml_new_bit (imhtml, TYPE_TEXT, ws, bold, italics, underline, strike, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2642 fonts ? fonts->data : NULL, bg, url, pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2643 #define NEW_SMILEY_BIT gtk_imhtml_new_bit (imhtml, TYPE_SMILEY, ws, bold, italics, underline, strike, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2644 fonts ? fonts->data : NULL, bg, url, pre)
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2645 #define NEW_SEP_BIT gtk_imhtml_new_bit (imhtml, TYPE_SEP, NULL, 0, 0, 0, 0, NULL, bg, NULL, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2646 #define NEW_BR_BIT gtk_imhtml_new_bit (imhtml, TYPE_BR, NULL, 0, 0, 0, 0, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2647 fonts ? fonts->data : NULL, bg, NULL, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2648 #define NEW_COMMENT_BIT gtk_imhtml_new_bit (imhtml, TYPE_COMMENT, ws, bold, italics, underline, strike, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2649 fonts ? fonts->data : NULL, bg, url, pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2650
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2651 #define NEW_BIT(bit) { GtkIMHtmlBit *tmp = bit; if (tmp != NULL) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2652 newbits = g_list_append (newbits, tmp); }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2653
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2654 #define UPDATE_BG_COLORS \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2655 { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2656 GdkColormap *cmap; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2657 GList *rev; \
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2658 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2659 rev = g_list_last (newbits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2660 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2661 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2662 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2663 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2664 bit->bg = gdk_color_copy (bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2665 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2666 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2667 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2668 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2669 if (!rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2670 rev = g_list_last (imhtml->bits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2671 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2672 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2673 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2674 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2675 bit->bg = gdk_color_copy (bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2676 gdk_color_alloc (cmap, bit->bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2677 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2678 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2679 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2680 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2681 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2682 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2683
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2684 static gboolean
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2685 is_amp_escape (const gchar *string,
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2686 gchar *replace,
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2687 gint *length)
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2688 {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2689 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2690 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2691 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2692
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2693 if (!g_strncasecmp (string, "&amp;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2694 *replace = '&';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2695 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2696 } else if (!g_strncasecmp (string, "&lt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2697 *replace = '<';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2698 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2699 } else if (!g_strncasecmp (string, "&gt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2700 *replace = '>';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2701 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2702 } else if (!g_strncasecmp (string, "&nbsp;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2703 *replace = ' ';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2704 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2705 } else if (!g_strncasecmp (string, "&copy;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2706 *replace = '©';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2707 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2708 } else if (!g_strncasecmp (string, "&quot;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2709 *replace = '\"';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2710 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2711 } else if (!g_strncasecmp (string, "&reg;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2712 *replace = '®';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2713 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2714 } else if (*(string + 1) == '#') {
2022
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
2715 guint pound = 0;
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
2716 if (sscanf (string, "&#%u;", &pound) == 1) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2717 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2718 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2719 *replace = (gchar)pound;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2720 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2721 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2722 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2723 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2724 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2725 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2726 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2727 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2728 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2729
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2730 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2731 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2732
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2733 GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2734 gtk_imhtml_append_text (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2735 const gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2736 GtkIMHtmlOptions options)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2737 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2738 const gchar *c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2739 gboolean intag = FALSE;
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2740 gint tagquote = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2741 gboolean incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2742 gchar *ws;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2743 gchar *tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2744 gint wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2745 gint tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2746 int smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2747 GList *newbits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2748
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2749 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2750 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2751 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2752 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2753 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2754 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2755 title = 0,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2756 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2757 GSList *fonts = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2758 GdkColor *bg = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2759 gchar *url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2760
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2761 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2762 gboolean scrolldown = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2763
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2764 GString *retval = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2765
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2766 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2767 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2768 g_return_val_if_fail (text != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2769
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2770 if (options & GTK_IMHTML_RETURN_LOG)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2771 retval = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2772
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2773 vadj = GTK_LAYOUT (imhtml)->vadjustment;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2774 if ((vadj->value < imhtml->y - GTK_WIDGET (imhtml)->allocation.height) &&
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2775 (vadj->upper >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2776 scrolldown = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2777
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2778 c = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2779 ws = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2780 tag = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2781
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2782 ws [0] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2783
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2784 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2785 if (*c == '<') {
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2786 if (intag && (tagquote != 1)) {
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2787 char *d;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2788 tag [tpos] = 0;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2789 d = tag;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2790 while (*d) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2791 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2792 ws [wpos] = 0;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2793 wpos = 0;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2794 NEW_BIT (NEW_TEXT_BIT);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2795 g_snprintf (ws, smilelen + 1, "%s", d);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2796 NEW_BIT (NEW_SMILEY_BIT);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2797 d += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2798 } else if (*d == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2799 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2800 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2801 if (is_amp_escape (d, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2802 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2803 d += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2804 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2805 ws [wpos++] = *d++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2806 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2807 } else if (*d == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2808 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2809 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2810 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2811 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2812 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2813 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2814 d++;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2815 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2816 ws [wpos++] = *d++;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2817 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2818 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2819 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2820 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2821
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2822 if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2823 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2825 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2826
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2827 if (!g_strncasecmp (c, "<!--", strlen ("<!--"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2828 if (!(options & GTK_IMHTML_NO_COMMENTS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2829 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2830 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2831 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2832 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2833 incomment = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2834 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2835 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2836 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2837 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2838 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2839 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2840 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2841 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2842
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2843 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2844 intag = TRUE;
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2845 tagquote = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2846 } else if (incomment && (*c == '-') && !g_strncasecmp (c, "-->", strlen ("-->"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2847 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2848 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2849 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2850 tmp = g_strdup (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2851 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2852 strcat (ws, tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2853 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2854 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2855 strcat (ws, tmp + strlen ("<!--"));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2856 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2857 NEW_BIT (NEW_COMMENT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2858 incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2859 c += strlen ("-->");
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2860 } else if (*c == '>' && intag && (tagquote != 1)) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861 gboolean got_tag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2862 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2863 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2864 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2865
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2866 if (!g_strcasecmp (tag, "<B>") || !g_strcasecmp (tag, "<BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2867 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2868 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869 bold++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2870 } else if (!g_strcasecmp (tag, "</B>") || !g_strcasecmp (tag, "</BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2871 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2872 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2873 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2874 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2875 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2876 } else if (!g_strcasecmp (tag, "<I>") || !g_strcasecmp (tag, "<ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2877 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2878 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2879 italics++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2880 } else if (!g_strcasecmp (tag, "</I>") || !g_strcasecmp (tag, "</ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2881 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2882 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2883 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2884 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2885 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2886 } else if (!g_strcasecmp (tag, "<U>") || !g_strcasecmp (tag, "<UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2887 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2888 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2889 underline++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2890 } else if (!g_strcasecmp (tag, "</U>") || !g_strcasecmp (tag, "</UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2891 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2892 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2893 if (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2894 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2895 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2896 } else if (!g_strcasecmp (tag, "<S>") || !g_strcasecmp (tag, "<STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2897 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2898 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2899 strike++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2900 } else if (!g_strcasecmp (tag, "</S>") || !g_strcasecmp (tag, "</STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2901 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2902 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2903 if (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2904 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2905 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2906 } else if (!g_strcasecmp (tag, "<SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2907 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2908 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2909 sub++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2910 } else if (!g_strcasecmp (tag, "</SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2911 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2912 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2913 if (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2914 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2915 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2916 } else if (!g_strcasecmp (tag, "<SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2917 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2918 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2919 sup++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2920 } else if (!g_strcasecmp (tag, "</SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2921 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2922 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2923 if (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2924 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2925 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2926 } else if (!g_strcasecmp (tag, "<PRE>")) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2927 got_tag = TRUE;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2928 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2929 pre++;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2930 } else if (!g_strcasecmp (tag, "</PRE>")) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2931 got_tag = TRUE;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2932 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2933 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2934 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2935 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2936 } else if (!g_strcasecmp (tag, "<TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2937 if (options & GTK_IMHTML_NO_TITLE) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2938 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2939 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2940 title++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2941 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2942 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2943 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2944 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2945 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2946 } else if (!g_strcasecmp (tag, "</TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2947 if (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2948 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2949 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2950 ws [wpos] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2951 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2952 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2953 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2954 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2955 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2956 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2957 } else if (!g_strcasecmp (tag, "<BR>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2958 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2959 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2960 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2961 } else if (!g_strcasecmp (tag, "<HR>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2962 !g_strncasecmp (tag, "<HR ", strlen ("<HR "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2963 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2964 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2965 NEW_BIT (NEW_SEP_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2966 } else if (!g_strncasecmp (tag, "<FONT ", strlen ("<FONT "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2967 gchar *t, *e, *a, *value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2968 FontDetail *font = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2969 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2970 gint saw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2971 gint i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2972
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2973 t = tag + strlen ("<FONT ");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2974
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2975 while (*t != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2976 value = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2977 saw = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2978
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2979 while (g_strncasecmp (t, "COLOR=", strlen ("COLOR="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2980 && g_strncasecmp (t, "BACK=", strlen ("BACK="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2981 && g_strncasecmp (t, "FACE=", strlen ("FACE="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2982 && g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2983 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2984 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2985 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2986 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2987 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2988 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2989 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2990 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2991 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2992
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2993 if (!g_strncasecmp (t, "COLOR=", strlen ("COLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2994 t += strlen ("COLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2995 saw = 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2996 } else if (!g_strncasecmp (t, "BACK=", strlen ("BACK="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2997 t += strlen ("BACK=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2998 saw = 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2999 } else if (!g_strncasecmp (t, "FACE=", strlen ("FACE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3000 t += strlen ("FACE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3001 saw = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3002 } else if (!g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3003 t += strlen ("SIZE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3004 saw = 4;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3005 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3006
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3007 if (!saw)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3008 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3009
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3010 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3011 e = a = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3012 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3013 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3014 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3015 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3016 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3017 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3018 *t = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3019 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3020 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3021 e = a = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3022 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3023 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3024 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3025 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3026 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3027 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3028
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3029 if (value == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3030 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3031
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3032 if (font == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3033 font = g_new0 (FontDetail, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3034
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3035 switch (saw) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3036 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3037 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3038 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3039 if ( (font->fore == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3040 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3041 font->fore = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3042 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3043 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3044 case 2:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3045 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3046 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3047 if ( (font->back == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3048 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3049 font->back = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3050 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3051 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3052 case 3:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3053 if ( (font->face == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3054 !(options & GTK_IMHTML_NO_FONTS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3055 font->face = g_strdup (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3056 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3057 case 4:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3058 if ((font->size != 0) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3059 (options & GTK_IMHTML_NO_SIZES))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3060 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3061
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3062 if (isdigit ((gint) value [0])) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3063 for (i = 0; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3064 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3065 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3066 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3067 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3068
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3069 sscanf (value, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3070 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3071 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3072
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3073 if ((value [0] == '+') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3074 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3075 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3076 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3077 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3078 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3079
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3080 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3081 font->size += 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3082 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3083 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3084
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3085 if ((value [0] == '-') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3086 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3087 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3088 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3089 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3090 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3091
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3092 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3093 font->size = MIN (font->size, 2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3094 font->size = 3 - font->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3095 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3096 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3097
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3098 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3099 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3100
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3101 g_free (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3102 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3103
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
3104 if (!font || !(font->size || font->face || font->fore || font->back)) {
2622
733471f39ac9 [gaim-migrate @ 2635]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2621
diff changeset
3105 g_free (font);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3106 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3107 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3108 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3109 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3110
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
3111 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3112
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3113 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3114 FontDetail *oldfont = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3115 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3116 font->size = oldfont->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3117 if (!font->face)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3118 font->face = g_strdup (oldfont->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3119 if (!font->fore && oldfont->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3120 font->fore = gdk_color_copy (oldfont->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3121 if (!font->back && oldfont->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3122 font->back = gdk_color_copy (oldfont->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3123 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3124 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3125 font->size = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3126 if (!font->face)
2140
66a84ff0445a [gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2116
diff changeset
3127 font->face = g_strdup (DEFAULT_FONT_NAME);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3128 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3129
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3130 fonts = g_slist_prepend (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3131 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3132 } else if (!g_strcasecmp (tag, "</FONT>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3133 FontDetail *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3134
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3135 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3136 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3137 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3138 font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3139 fonts = g_slist_remove (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3140 g_free (font->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3141 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3142 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3143 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3144 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3145 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3146 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3147 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3148 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3149 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3150 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3151 } else if (!g_strncasecmp (tag, "<BODY ", strlen ("<BODY "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3152 gchar *t, *e, *color = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3153 GdkColor *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3154
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3155 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3156
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3157 if (!(options & GTK_IMHTML_NO_COLOURS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3158 t = tag + strlen ("<BODY");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3159 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3160 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3161 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3162 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3163 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3164 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3165 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3166 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3167 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3168 } while (g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3169
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3170 if (!g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3171 t += strlen ("BGCOLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3172 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3173 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3174 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3175 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3176 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3177 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3178 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3179 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3180 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3181 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3182 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3183 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3184 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3185 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3186
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3187 if (color != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3188 tmp = gtk_imhtml_get_color (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3189 g_free (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3190 if (tmp != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3191 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3192 bg = tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3193 UPDATE_BG_COLORS;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3194 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3195 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3196 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3197 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3198 } else if (!g_strncasecmp (tag, "<A ", strlen ("<A "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3199 gchar *t, *e;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3200
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3201 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3202 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3203
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3204 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3205 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3206 url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3207
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3208 t = tag + strlen ("<A");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3209 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3210 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3211 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3212 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3213 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3214 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3215 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3216 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3217 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3218 } while (g_strncasecmp (t, "HREF=", strlen ("HREF=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3219
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3220 if (!g_strncasecmp (t, "HREF=", strlen ("HREF="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3221 t += strlen ("HREF=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3222 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3223 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3224 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3225 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3226 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3227 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3228 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3229 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3230 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3231 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3232 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3233 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3234 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3235 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3236 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3237 } else if (!g_strcasecmp (tag, "</A>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3238 if (url != NULL) {
1524
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3239 got_tag = TRUE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3240 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3241 g_free (url);
1524
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3242 url = NULL;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3243 } else {
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3244 intag = FALSE;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3245 tpos = 0;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3246 continue;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3247 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3248 } else if (!g_strncasecmp (tag, "<IMG ", strlen ("<IMG "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3249 gchar *t, *e, *src = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3250 gchar *copy = g_strdup (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3251 gchar **xpm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3252 GdkColor *clr = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3253 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3254
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3255 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3256 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3257
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3258 if (imhtml->img == NULL) {
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3259 ws [wpos] = 0;
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3260 strcat (ws, copy);
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3261 wpos = strlen (ws);
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3262 g_free (copy);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3263 continue;
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3264 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3265
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3266 t = tag + strlen ("<IMG");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3267 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3268 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3269 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3270 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3271 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3272 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3273 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3274 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3275 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3276 } while (g_strncasecmp (t, "SRC=", strlen ("SRC=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3277
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3278 if (!g_strncasecmp (t, "SRC=", strlen ("SRC="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3279 t += strlen ("SRC=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3280 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3281 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3282 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3283 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3284 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3285 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3286 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3287 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3288 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3289 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3290 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3291 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3292 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3293 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3294 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3295
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3296 if (src == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3297 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3298 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3299 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3300 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3301 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3302 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3303
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3304 xpm = (* imhtml->img) (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3305 if (xpm == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3306 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3307 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3308 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3309 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3310 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3311 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3312 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3313
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3314 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3315
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3316 if (!fonts || ((clr = ((FontDetail *)fonts->data)->back) == NULL))
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
3317 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3318
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3319 if (!GTK_WIDGET_REALIZED (imhtml))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3320 gtk_widget_realize (GTK_WIDGET (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3321
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3322 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3323 bit->type = TYPE_IMG;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3324 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3325 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3326 clr,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3327 xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3328 if (url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3329 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3330
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3331 NEW_BIT (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3332
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3333 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3334
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3335 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3336 } else if (!g_strcasecmp (tag, "<P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3337 !g_strcasecmp (tag, "</P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3338 !g_strncasecmp (tag, "<P ", strlen ("<P ")) ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
3339 !g_strcasecmp (tag, "<H3>") ||
1473
38e8391aa563 [gaim-migrate @ 1483]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1472
diff changeset
3340 !g_strncasecmp (tag, "<H3 ", strlen ("<H3 ")) ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
3341 !g_strcasecmp (tag, "</H3>") ||
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3342 !g_strcasecmp (tag, "<HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3343 !g_strcasecmp (tag, "</HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3344 !g_strcasecmp (tag, "<BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3345 !g_strcasecmp (tag, "</BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3346 !g_strcasecmp (tag, "<FONT>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3347 !g_strcasecmp (tag, "<HEAD>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3348 !g_strcasecmp (tag, "</HEAD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3349 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3350 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3351 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3352 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3353
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3354 if (!got_tag) {
1463
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3355 char *d;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3356 tag [tpos] = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3357 d = tag;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3358 while (*d) {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3359 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3360 ws [wpos] = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3361 wpos = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3362 NEW_BIT (NEW_TEXT_BIT);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3363 g_snprintf (ws, smilelen + 1, "%s", d);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3364 NEW_BIT (NEW_SMILEY_BIT);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3365 d += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3366 } else if (*d == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3367 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3368 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3369 if (is_amp_escape (d, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3370 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3371 d += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3372 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3373 ws [wpos++] = *d++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3374 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3375 } else if (*d == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3376 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3377 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3378 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3379 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3380 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3381 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3382 d++;
1463
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3383 } else {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3384 ws [wpos++] = *d++;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3385 }
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3386 }
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3387 tpos = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3388 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3389 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3390 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3391 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3392 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3393 } else if (*c == '&' && !intag) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3394 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3395 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3396 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3397 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3398 c += length;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3399 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3400 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3401 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3402 } else if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3403 if (*c == '\"')
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
3404 tagquote++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3405 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3406 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3407 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3408 } else if (((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3409 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3410 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3411 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3412 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3413 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3414 c += smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3415 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3416 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3417 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3418 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3419 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3420 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3421 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3422 c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3423 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3424 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3425 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3426 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3427
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3428 if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3429 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3430 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3431 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3432 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3433 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3434 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3435 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3436 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3437 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3438 c += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3439 } else if (*c == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3440 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3441 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3442 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3443 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3444 c += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3445 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3446 ws [wpos++] = *c++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3447 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3448 } else if (*c == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3449 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3450 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3451 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3452 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3453 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3454 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3455 c++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3456 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3457 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3458 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3459 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3460 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3461 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3462 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3463 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3464 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3465 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3466 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3467 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3468 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3469 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3470 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3471 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3472 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3473 c += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3474 } else if (*c == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3475 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3476 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3477 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3478 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3479 c += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3480 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3481 ws [wpos++] = *c++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3482 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3483 } else if (*c == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3484 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3485 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3486 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3487 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3488 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3489 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3490 c++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3491 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3492 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3493 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3494 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3495 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3496
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3497 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3498 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3499
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3500 while (newbits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3501 GtkIMHtmlBit *bit = newbits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3502 imhtml->bits = g_list_append (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3503 newbits = g_list_remove (newbits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3504 gtk_imhtml_draw_bit (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3505 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3506
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3507 GTK_LAYOUT (imhtml)->height = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3508 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3509 gtk_signal_emit_by_name (GTK_OBJECT (GTK_LAYOUT (imhtml)->vadjustment), "changed");
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3510
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3511 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3512
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3513 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3514 if (!(options & GTK_IMHTML_NO_SCROLL) &&
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3515 scrolldown &&
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3516 (imhtml->y >= MAX (1,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3517 (GTK_WIDGET (imhtml)->allocation.height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3518 (GTK_WIDGET (imhtml)->style->ythickness + BORDER_SIZE) * 2))))
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3519 gtk_adjustment_set_value (vadj, imhtml->y -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3520 MAX (1, (GTK_WIDGET (imhtml)->allocation.height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3521 (GTK_WIDGET (imhtml)->style->ythickness +
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3522 BORDER_SIZE) * 2)));
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3523 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3524 if (!(options & GTK_IMHTML_NO_SCROLL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3525 scrolldown &&
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3526 (imhtml->y >= MAX (1,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3527 (GTK_WIDGET (imhtml)->allocation.height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3528 (GTK_WIDGET (imhtml)->style->klass->ythickness + BORDER_SIZE) * 2))))
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3529 gtk_adjustment_set_value (vadj, imhtml->y -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3530 MAX (1, (GTK_WIDGET (imhtml)->allocation.height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3531 (GTK_WIDGET (imhtml)->style->klass->ythickness +
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3532 BORDER_SIZE) * 2)));
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3533 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3534
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3535 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3536 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3537 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3538 retval = g_string_append (retval, "</A>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3539 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3540 if (bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3541 gdk_color_free (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3542 while (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3543 FontDetail *font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3544 fonts = g_slist_remove (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3545 g_free (font->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3546 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3547 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3548 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3549 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3550 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3551 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3552 retval = g_string_append (retval, "</FONT>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3553 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3554 if (retval) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3555 while (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3556 retval = g_string_append (retval, "</B>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3557 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3558 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3559 while (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3560 retval = g_string_append (retval, "</I>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3561 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3562 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3563 while (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3564 retval = g_string_append (retval, "</U>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3565 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3566 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3567 while (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3568 retval = g_string_append (retval, "</S>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3569 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3570 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3571 while (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3572 retval = g_string_append (retval, "</SUB>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3573 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3574 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3575 while (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3576 retval = g_string_append (retval, "</SUP>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3577 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3578 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3579 while (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3580 retval = g_string_append (retval, "</TITLE>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3581 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3582 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3583 while (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3584 retval = g_string_append (retval, "</PRE>");
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3585 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3586 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3587 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3588 g_free (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3589 g_free (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3590
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3591 return retval;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3592 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3593
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3594 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3595 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3596 {
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3597 GtkLayout *layout;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3598
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3599 g_return_if_fail (imhtml != NULL);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3600 g_return_if_fail (GTK_IS_IMHTML (imhtml));
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3601
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3602 layout = GTK_LAYOUT (imhtml);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3603
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3604 while (imhtml->bits) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3605 GtkIMHtmlBit *bit = imhtml->bits->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3606 imhtml->bits = g_list_remove (imhtml->bits, bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3607 if (bit->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3608 g_free (bit->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3609 if (bit->font)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3610 gdk_font_unref (bit->font);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3611 if (bit->fore)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3612 gdk_color_free (bit->fore);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3613 if (bit->back)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3614 gdk_color_free (bit->back);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3615 if (bit->bg)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3616 gdk_color_free (bit->bg);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3617 if (bit->url)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3618 g_free (bit->url);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3619 if (bit->pm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3620 gdk_pixmap_unref (bit->pm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3621 if (bit->bm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3622 gdk_bitmap_unref (bit->bm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3623 while (bit->chunks) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3624 struct line_info *li = bit->chunks->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3625 if (li->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3626 g_free (li->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3627 bit->chunks = g_list_remove (bit->chunks, li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3628 g_free (li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3629 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3630 g_free (bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3631 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3632
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3633 while (imhtml->urls) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3634 g_free (imhtml->urls->data);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3635 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3636 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3637
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3638 if (imhtml->selected_text) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3639 g_string_free (imhtml->selected_text, TRUE);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3640 imhtml->selected_text = g_string_new ("");
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3641 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3642
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3643 imhtml->sel_startx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3644 imhtml->sel_starty = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3645 imhtml->sel_endx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3646 imhtml->sel_endx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3647 imhtml->sel_endchunk = NULL;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3648
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3649 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3650 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3651 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3652 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3653 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3654 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3655 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3656 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3657 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3658
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3659 if (imhtml->scroll_timer) {
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3660 gtk_timeout_remove (imhtml->scroll_timer);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3661 imhtml->scroll_timer = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3662 }
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3663
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3664 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3665
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3666 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3667 imhtml->y = TOP_BORDER;
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3668 imhtml->xsize = 0;
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3669 imhtml->llheight = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3670 imhtml->llascent = 0;
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3671 if (imhtml->line)
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3672 g_list_free (imhtml->line);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3673 imhtml->line = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3674
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3675 layout->hadjustment->page_size = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3676 layout->hadjustment->page_increment = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3677 layout->hadjustment->lower = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3678 layout->hadjustment->upper = imhtml->x;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3679 gtk_adjustment_set_value (layout->hadjustment, 0);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3680
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3681 layout->vadjustment->page_size = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3682 layout->vadjustment->page_increment = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3683 layout->vadjustment->lower = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3684 layout->vadjustment->upper = imhtml->y;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3685 gtk_adjustment_set_value (layout->vadjustment, 0);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3686
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3687 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3688 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3689
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3690 if (GTK_WIDGET_REALIZED (GTK_WIDGET (imhtml)))
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3691 gdk_window_clear (GTK_LAYOUT (imhtml)->bin_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3692 }
2363
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3693
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3694 void
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3695 gtk_imhtml_page_up (GtkIMHtml *imhtml)
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3696 {
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3697 GtkAdjustment *vadj;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3698
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3699 g_return_if_fail (imhtml != NULL);
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3700 g_return_if_fail (GTK_IS_IMHTML (imhtml));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3701
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3702 vadj = GTK_LAYOUT (imhtml)->vadjustment;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3703 gtk_adjustment_set_value (vadj, MAX (vadj->value - vadj->page_increment,
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3704 vadj->lower));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3705 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed");
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3706 }
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3707
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3708 void
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3709 gtk_imhtml_page_down (GtkIMHtml *imhtml)
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3710 {
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3711 GtkAdjustment *vadj;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3712
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3713 g_return_if_fail (imhtml != NULL);
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3714 g_return_if_fail (GTK_IS_IMHTML (imhtml));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3715
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3716 vadj = GTK_LAYOUT (imhtml)->vadjustment;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3717 gtk_adjustment_set_value (vadj, MIN (vadj->value + vadj->page_increment,
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3718 vadj->upper - vadj->page_size));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3719 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed");
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3720 }