Mercurial > pidgin.yaz
annotate src/gtkimhtml.c @ 2631:a2cf3cac7e66
[gaim-migrate @ 2644]
bah. this is better.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 27 Oct 2001 23:46:12 +0000 |
parents | 733471f39ac9 |
children | c4ad36781d1b |
rev | line source |
---|---|
1428 | 1 /* |
2 * GtkIMHtml | |
3 * | |
4 * Copyright (C) 2000, Eric Warmenhoven <warmenhoven@yahoo.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
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 | 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 | 28 #include <gtk/gtk.h> |
29 #include <string.h> | |
30 #include <ctype.h> | |
31 #include <stdio.h> | |
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 | 37 |
38 #include "pixmaps/angel.xpm" | |
39 #include "pixmaps/bigsmile.xpm" | |
40 #include "pixmaps/burp.xpm" | |
41 #include "pixmaps/crossedlips.xpm" | |
42 #include "pixmaps/cry.xpm" | |
43 #include "pixmaps/embarrassed.xpm" | |
44 #include "pixmaps/kiss.xpm" | |
45 #include "pixmaps/moneymouth.xpm" | |
46 #include "pixmaps/sad.xpm" | |
47 #include "pixmaps/scream.xpm" | |
48 #include "pixmaps/smile.xpm" | |
49 #include "pixmaps/smile8.xpm" | |
50 #include "pixmaps/think.xpm" | |
51 #include "pixmaps/tongue.xpm" | |
52 #include "pixmaps/wink.xpm" | |
53 #include "pixmaps/yell.xpm" | |
54 | |
55 #define DEFAULT_FONT_NAME "helvetica" | |
56 #define MAX_SIZE 7 | |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
57 #define MAX_FONTS 32767 |
1428 | 58 |
59 gint font_sizes [] = { 80, 100, 120, 140, 200, 300, 400 }; | |
60 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
61 #define BORDER_SIZE 2 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
62 #define TOP_BORDER 10 |
1428 | 63 #define MIN_HEIGHT 20 |
64 #define HR_HEIGHT 2 | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
65 #define TOOLTIP_TIMEOUT 500 |
1428 | 66 |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
67 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
68 #define COLOR_MOD 0x8000 |
1647
23b734cf1161
[gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1626
diff
changeset
|
69 #define COLOR_DIFF 0x800 |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
70 |
1428 | 71 #define TYPE_TEXT 0 |
72 #define TYPE_SMILEY 1 | |
73 #define TYPE_IMG 2 | |
74 #define TYPE_SEP 3 | |
75 #define TYPE_BR 4 | |
76 #define TYPE_COMMENT 5 | |
77 | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
78 #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
|
79 |
1428 | 80 typedef struct _GtkIMHtmlBit GtkIMHtmlBit; |
81 typedef struct _FontDetail FontDetail; | |
82 | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
83 struct _GtkSmileyTree { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
84 GString *values; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
85 GtkSmileyTree **children; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
86 gchar **image; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
87 }; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
88 |
2596
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
89 static gchar* |
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
90 getcharset () |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
91 { |
2596
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
92 static gchar charset [64]; |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
93 #ifdef HAVE_LANGINFO_CODESET |
2596
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
94 gchar *ch = nl_langinfo (CODESET); |
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
95 if (!g_strncasecmp (ch, "iso-", 4)) |
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
96 g_snprintf (charset, sizeof (charset), "iso%s", ch + 4); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
97 else |
2596
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
98 g_snprintf (charset, sizeof (charset), ch); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
99 #else |
2596
35c23df11d16
[gaim-migrate @ 2609]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2583
diff
changeset
|
100 g_snprintf (charset, sizeof (charset), "iso8859-*"); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
101 #endif |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
102 return charset; |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
103 } |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
104 |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
105 static GtkSmileyTree* |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
106 gtk_smiley_tree_new () |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
107 { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
108 return g_new0 (GtkSmileyTree, 1); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
109 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
110 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
111 static void |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
112 gtk_smiley_tree_insert (GtkSmileyTree *tree, |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
113 const gchar *text, |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
114 gchar **image) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
115 { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
116 GtkSmileyTree *t = tree; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
117 const gchar *x = text; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
118 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
119 if (!strlen (x)) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
120 return; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
121 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
122 while (*x) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
123 gchar *pos; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
124 gint index; |
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 (!t->values) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
127 t->values = g_string_new (""); |
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 pos = strchr (t->values->str, *x); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
130 if (!pos) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
131 t->values = g_string_append_c (t->values, *x); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
132 index = t->values->len - 1; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
133 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
134 t->children [index] = g_new0 (GtkSmileyTree, 1); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
135 } else |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
136 index = (int) pos - (int) t->values->str; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
137 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
138 t = t->children [index]; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
139 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
140 x++; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
141 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
142 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
143 t->image = image; |
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 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
146 static void |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
147 gtk_smiley_tree_remove (GtkSmileyTree *tree, |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
148 const gchar *text) |
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 GtkSmileyTree *t = tree; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
151 const gchar *x = text; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
152 gint len = 0; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
153 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
154 while (*x) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
155 gchar *pos; |
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 if (t->image) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
158 t->image = NULL; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
159 return; |
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 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
162 if (!t->values) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
163 return; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
164 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
165 pos = strchr (t->values->str, *x); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
166 if (pos) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
167 t = t->children [(int) pos - (int) t->values->str]; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
168 else |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
169 return; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
170 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
171 x++; len++; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
172 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
173 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
174 if (t->image) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
175 t->image = NULL; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
176 } |
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 static gint |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
179 gtk_smiley_tree_lookup (GtkSmileyTree *tree, |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
180 const gchar *text) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
181 { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
182 GtkSmileyTree *t = tree; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
183 const gchar *x = text; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
184 gint len = 0; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
185 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
186 while (*x) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
187 gchar *pos; |
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 if (t->image) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
190 return len; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
191 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
192 if (!t->values) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
193 return 0; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
194 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
195 pos = strchr (t->values->str, *x); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
196 if (pos) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
197 t = t->children [(int) pos - (int) t->values->str]; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
198 else |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
199 return 0; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
200 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
201 x++; len++; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
202 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
203 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
204 if (t->image) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
205 return len; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
206 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
207 return 0; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
208 } |
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 static gchar** |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
211 gtk_smiley_tree_image (GtkSmileyTree *tree, |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
212 const gchar *text) |
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 GtkSmileyTree *t = tree; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
215 const gchar *x = text; |
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 while (*x) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
218 gchar *pos; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
219 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
220 if (!t->values) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
221 return NULL; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
222 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
223 pos = strchr (t->values->str, *x); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
224 if (pos) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
225 t = t->children [(int) pos - (int) t->values->str]; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
226 } else |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
227 return NULL; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
228 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
229 x++; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
230 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
231 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
232 return t->image; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
233 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
234 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
235 static void |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
236 gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
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 GSList *list = g_slist_append (NULL, tree); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
239 |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
240 while (list) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
241 GtkSmileyTree *t = list->data; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
242 gint i; |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
243 list = g_slist_remove(list, t); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
244 if (t->values) { |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
245 for (i = 0; i < t->values->len; i++) |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
246 list = g_slist_append (list, t->children [i]); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
247 g_string_free (t->values, TRUE); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
248 g_free (t->children); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
249 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
250 g_free (t); |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
251 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
252 } |
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
253 |
1428 | 254 struct _GtkIMHtmlBit { |
255 gint type; | |
256 | |
257 gchar *text; | |
258 GdkPixmap *pm; | |
259 GdkBitmap *bm; | |
260 | |
261 GdkFont *font; | |
262 GdkColor *fore; | |
263 GdkColor *back; | |
264 GdkColor *bg; | |
265 gboolean underline; | |
266 gboolean strike; | |
267 gchar *url; | |
268 | |
269 GList *chunks; | |
270 }; | |
271 | |
272 struct _FontDetail { | |
273 gushort size; | |
274 gchar *face; | |
275 GdkColor *fore; | |
276 GdkColor *back; | |
277 }; | |
278 | |
279 struct line_info { | |
280 gint x; | |
281 gint y; | |
282 gint width; | |
283 gint height; | |
284 gint ascent; | |
285 | |
286 gboolean selected; | |
287 gchar *sel_start; | |
288 gchar *sel_end; | |
289 | |
290 gchar *text; | |
291 GtkIMHtmlBit *bit; | |
292 }; | |
293 | |
294 struct url_widget { | |
295 gint x; | |
296 gint y; | |
297 gint width; | |
298 gint height; | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
299 GtkIMHtmlBit *bit; |
1428 | 300 }; |
301 | |
302 static GtkLayoutClass *parent_class = NULL; | |
303 | |
304 enum { | |
305 TARGET_STRING, | |
306 TARGET_TEXT, | |
307 TARGET_COMPOUND_TEXT | |
308 }; | |
309 | |
310 enum { | |
311 URL_CLICKED, | |
312 LAST_SIGNAL | |
313 }; | |
314 static guint signals [LAST_SIGNAL] = { 0 }; | |
315 | |
316 static void gtk_imhtml_draw_bit (GtkIMHtml *, GtkIMHtmlBit *); | |
317 static GdkColor *gtk_imhtml_get_color (const gchar *); | |
318 static gint gtk_imhtml_motion_notify_event (GtkWidget *, GdkEventMotion *); | |
319 | |
320 static void | |
321 gtk_imhtml_destroy (GtkObject *object) | |
322 { | |
323 GtkIMHtml *imhtml; | |
324 | |
325 imhtml = GTK_IMHTML (object); | |
326 | |
327 while (imhtml->bits) { | |
328 GtkIMHtmlBit *bit = imhtml->bits->data; | |
329 imhtml->bits = g_list_remove (imhtml->bits, bit); | |
330 if (bit->text) | |
331 g_free (bit->text); | |
332 if (bit->font) | |
333 gdk_font_unref (bit->font); | |
334 if (bit->fore) | |
335 gdk_color_free (bit->fore); | |
336 if (bit->back) | |
337 gdk_color_free (bit->back); | |
338 if (bit->bg) | |
339 gdk_color_free (bit->bg); | |
340 if (bit->url) | |
341 g_free (bit->url); | |
342 if (bit->pm) | |
343 gdk_pixmap_unref (bit->pm); | |
344 if (bit->bm) | |
345 gdk_bitmap_unref (bit->bm); | |
346 while (bit->chunks) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
347 struct line_info *li = bit->chunks->data; |
1428 | 348 if (li->text) |
349 g_free (li->text); | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
350 bit->chunks = g_list_remove (bit->chunks, li); |
1428 | 351 g_free (li); |
352 } | |
353 g_free (bit); | |
354 } | |
355 | |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
356 if (imhtml->line) |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
357 g_list_free (imhtml->line); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
358 |
1428 | 359 while (imhtml->urls) { |
360 g_free (imhtml->urls->data); | |
361 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data); | |
362 } | |
363 | |
364 if (imhtml->selected_text) | |
365 g_string_free (imhtml->selected_text, TRUE); | |
366 | |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
367 if (imhtml->tip_timer) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
368 gtk_timeout_remove (imhtml->tip_timer); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
369 imhtml->tip_timer = 0; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
370 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
371 if (imhtml->tip_window) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
372 gtk_widget_destroy (imhtml->tip_window); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
373 imhtml->tip_window = NULL; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
374 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
375 imhtml->tip_bit = NULL; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
376 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
377 if (imhtml->default_font) |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
378 gdk_font_unref (imhtml->default_font); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
379 if (imhtml->default_fg_color) |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
380 gdk_color_free (imhtml->default_fg_color); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
381 if (imhtml->default_bg_color) |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
382 gdk_color_free (imhtml->default_bg_color); |
1428 | 383 |
384 gdk_cursor_destroy (imhtml->hand_cursor); | |
385 gdk_cursor_destroy (imhtml->arrow_cursor); | |
386 | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
387 gtk_smiley_tree_destroy (imhtml->smiley_data); |
1428 | 388 |
389 if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) | |
390 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); | |
391 } | |
392 | |
393 static void | |
394 gtk_imhtml_realize (GtkWidget *widget) | |
395 { | |
396 GtkIMHtml *imhtml; | |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
397 GdkWindowAttr attributes; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
398 gint attributes_mask; |
1428 | 399 |
400 g_return_if_fail (widget != NULL); | |
401 g_return_if_fail (GTK_IS_IMHTML (widget)); | |
402 | |
403 imhtml = GTK_IMHTML (widget); | |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
404 GTK_WIDGET_SET_FLAGS (imhtml, GTK_REALIZED); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
405 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
406 attributes.window_type = GDK_WINDOW_CHILD; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
407 attributes.x = widget->allocation.x; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
408 attributes.y = widget->allocation.y; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
409 attributes.width = widget->allocation.width; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
410 attributes.height = widget->allocation.height; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
411 attributes.wclass = GDK_INPUT_OUTPUT; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
412 attributes.visual = gtk_widget_get_visual (widget); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
413 attributes.colormap = gtk_widget_get_colormap (widget); |
2556
e284ab2882bd
[gaim-migrate @ 2569]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2541
diff
changeset
|
414 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK; |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
415 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
416 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
|
417 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
418 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
419 &attributes, attributes_mask); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
420 gdk_window_set_user_data (widget->window, widget); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
421 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
422 attributes.x = widget->style->klass->xthickness + BORDER_SIZE; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
423 attributes.y = widget->style->klass->xthickness + BORDER_SIZE; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
424 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
|
425 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
|
426 attributes.event_mask = gtk_widget_get_events (widget) |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
427 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
428 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
429 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
430 GTK_LAYOUT (imhtml)->bin_window = gdk_window_new (widget->window, |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
431 &attributes, attributes_mask); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
432 gdk_window_set_user_data (GTK_LAYOUT (imhtml)->bin_window, widget); |
1428 | 433 |
434 widget->style = gtk_style_attach (widget->style, widget->window); | |
435 | |
436 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor); | |
437 | |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
438 imhtml->default_font = gdk_font_ref (GTK_WIDGET (imhtml)->style->font); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
439 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
440 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
|
441 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
442 &widget->style->base [GTK_STATE_NORMAL]); |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
443 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
444 imhtml->default_fg_color = gdk_color_copy (>K_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
445 imhtml->default_bg_color = gdk_color_copy (>K_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
446 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
447 gdk_window_show (GTK_LAYOUT (imhtml)->bin_window); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
448 } |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
449 |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
450 static gboolean |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
451 similar_colors (GdkColor *bg, |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
452 GdkColor *fg) |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
453 { |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
454 if ((DIFF (bg->red, fg->red) < COLOR_DIFF) && |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
455 (DIFF (bg->green, fg->green) < COLOR_DIFF) && |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
456 (DIFF (bg->blue, fg->blue) < COLOR_DIFF)) { |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
457 fg->red = (0xff00 - COLOR_MOD > bg->red) ? |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
458 bg->red + COLOR_MOD : bg->red - COLOR_MOD; |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
459 fg->green = (0xff00 - COLOR_MOD > bg->green) ? |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
460 bg->green + COLOR_MOD : bg->green - COLOR_MOD; |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
461 fg->blue = (0xff00 - COLOR_MOD > bg->blue) ? |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
462 bg->blue + COLOR_MOD : bg->blue - COLOR_MOD; |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
463 return TRUE; |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
464 } |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
465 return FALSE; |
1428 | 466 } |
467 | |
468 static void | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
469 draw_text (GtkIMHtml *imhtml, |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
470 struct line_info *line) |
1428 | 471 { |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
472 GtkIMHtmlBit *bit; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
473 GdkGC *gc; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
474 GdkColormap *cmap; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
475 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
476 gfloat xoff, yoff; |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
477 GdkColor *bg, *fg; |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
478 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
479 if (GTK_LAYOUT (imhtml)->freeze_count) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
480 return; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
481 |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
482 bit = line->bit; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
483 gc = gdk_gc_new (window); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
484 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
485 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
486 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
487 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
488 if (bit->bg != NULL) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
489 gdk_color_alloc (cmap, bit->bg); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
490 gdk_gc_set_foreground (gc, bit->bg); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
491 bg = bit->bg; |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
492 } else { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
493 gdk_color_alloc (cmap, imhtml->default_bg_color); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
494 gdk_gc_set_foreground (gc, imhtml->default_bg_color); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
495 bg = imhtml->default_bg_color; |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
496 } |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
497 |
2338
2bf8a8131479
[gaim-migrate @ 2351]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2337
diff
changeset
|
498 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
|
499 line->width ? line->width : imhtml->xsize, line->height); |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
500 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
501 if (!line->text) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
502 gdk_gc_unref (gc); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
503 return; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
504 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
505 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
506 if (bit->back != NULL) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
507 gdk_color_alloc (cmap, bit->back); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
508 gdk_gc_set_foreground (gc, bit->back); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
509 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
|
510 gdk_string_width (bit->font, line->text), line->height); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
511 bg = bit->back; |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
512 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
513 |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
514 bg = gdk_color_copy (bg); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
515 |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
516 if (line->selected) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
517 gint width, x; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
518 gchar *start, *end; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
519 GdkColor col; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
520 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
521 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
522 start = line->sel_end; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
523 end = line->sel_start; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
524 } else { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
525 start = line->sel_start; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
526 end = line->sel_end; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
527 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
528 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
529 if (start == NULL) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
530 x = 0; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
531 else |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
532 x = gdk_text_width (bit->font, line->text, start - line->text); |
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 if (end == NULL) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
535 width = gdk_string_width (bit->font, line->text) - x; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
536 else |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
537 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
|
538 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
539 col.red = col.green = col.blue = 0xc000; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
540 gdk_color_alloc (cmap, &col); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
541 gdk_gc_set_foreground (gc, &col); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
542 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
543 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
|
544 width, line->height); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
545 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
546 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
547 if (bit->url) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
548 GdkColor *tc = gtk_imhtml_get_color ("#0000a0"); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
549 gdk_color_alloc (cmap, tc); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
550 gdk_gc_set_foreground (gc, tc); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
551 fg = gdk_color_copy (tc); |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
552 gdk_color_free (tc); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
553 } else if (bit->fore) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
554 gdk_color_alloc (cmap, bit->fore); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
555 gdk_gc_set_foreground (gc, bit->fore); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
556 fg = gdk_color_copy (bit->fore); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
557 } else { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
558 gdk_color_alloc (cmap, imhtml->default_fg_color); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
559 gdk_gc_set_foreground (gc, imhtml->default_fg_color); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
560 fg = gdk_color_copy (imhtml->default_fg_color); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
561 } |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
562 |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
563 if (similar_colors (bg, fg)) { |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
564 gdk_color_alloc (cmap, fg); |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
565 gdk_gc_set_foreground (gc, fg); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
566 } |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
567 gdk_color_free (bg); |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
568 gdk_color_free (fg); |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
569 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
570 gdk_draw_string (window, bit->font, gc, line->x - xoff, |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
571 line->y - yoff + line->ascent, line->text); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
572 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
573 if (bit->underline || bit->url) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
574 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
|
575 gdk_string_width (bit->font, line->text), 1); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
576 if (bit->strike) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
577 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
578 line->y - yoff + line->ascent - (bit->font->ascent / 2), |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
579 gdk_string_width (bit->font, line->text), 1); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
580 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
581 gdk_gc_unref (gc); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
582 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
583 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
584 static void |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
585 draw_img (GtkIMHtml *imhtml, |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
586 struct line_info *line) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
587 { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
588 GtkIMHtmlBit *bit; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
589 GdkGC *gc; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
590 GdkColormap *cmap; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
591 gint width, height, hoff; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
592 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
593 gfloat xoff, yoff; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
594 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
595 if (GTK_LAYOUT (imhtml)->freeze_count) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
596 return; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
597 |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
598 bit = line->bit; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
599 gdk_window_get_size (bit->pm, &width, &height); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
600 hoff = (line->height - height) / 2; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
601 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
602 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
603 gc = gdk_gc_new (window); |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
604 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
605 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
606 if (bit->bg != NULL) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
607 gdk_color_alloc (cmap, bit->bg); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
608 gdk_gc_set_foreground (gc, bit->bg); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
609 } else { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
610 gdk_color_alloc (cmap, imhtml->default_bg_color); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
611 gdk_gc_set_foreground (gc, imhtml->default_bg_color); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
612 } |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
613 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
614 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
|
615 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
616 if (bit->back != NULL) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
617 gdk_color_alloc (cmap, bit->back); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
618 gdk_gc_set_foreground (gc, bit->back); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
619 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
|
620 width, line->height); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
621 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
622 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
623 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
|
624 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
625 gdk_gc_unref (gc); |
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 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
628 static void |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
629 draw_line (GtkIMHtml *imhtml, |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
630 struct line_info *line) |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
631 { |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
632 GtkIMHtmlBit *bit; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
633 GdkDrawable *drawable; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
634 GdkColormap *cmap; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
635 GdkGC *gc; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
636 guint line_height; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
637 gfloat xoff, yoff; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
638 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
639 if (GTK_LAYOUT (imhtml)->freeze_count) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
640 return; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
641 |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
642 xoff = GTK_LAYOUT (imhtml)->hadjustment->value; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
643 yoff = GTK_LAYOUT (imhtml)->vadjustment->value; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
644 bit = line->bit; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
645 drawable = GTK_LAYOUT (imhtml)->bin_window; |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
646 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
647 gc = gdk_gc_new (drawable); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
648 |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
649 if (bit->bg != NULL) { |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
650 gdk_color_alloc (cmap, bit->bg); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
651 gdk_gc_set_foreground (gc, bit->bg); |
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 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
|
654 line->width, line->height); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
655 } |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
656 |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
657 gdk_color_alloc (cmap, imhtml->default_fg_color); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
658 gdk_gc_set_foreground (gc, imhtml->default_fg_color); |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
659 |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
660 line_height = line->height / 2; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
661 |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
662 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
|
663 line->width, line_height); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
664 |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
665 gdk_gc_unref (gc); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
666 } |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
667 |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
668 static void |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
669 gtk_imhtml_draw_focus (GtkWidget *widget) |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
670 { |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
671 GtkIMHtml *imhtml; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
672 gint x = 0, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
673 y = 0, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
674 w = 0, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
675 h = 0; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
676 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
677 imhtml = GTK_IMHTML (widget); |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
678 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
679 if (!GTK_WIDGET_DRAWABLE (widget)) |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
680 return; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
681 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
682 if (GTK_WIDGET_HAS_FOCUS (widget)) { |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
683 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
|
684 widget->allocation.width - 1, widget->allocation.height - 1); |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
685 x = 1; y = 1; w = 2; h = 2; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
686 } |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
687 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
688 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
689 GTK_SHADOW_IN, NULL, widget, "text", x, y, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
690 widget->allocation.width - w, widget->allocation.height - h); |
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 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
693 static void |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
694 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
695 { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
696 GList *bits; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
697 GtkIMHtmlBit *bit; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
698 GList *chunks; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
699 struct line_info *line; |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
700 gfloat x, y; |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2022
diff
changeset
|
701 gint width, height; |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
702 |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
703 x = GTK_LAYOUT (imhtml)->hadjustment->value; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
704 y = GTK_LAYOUT (imhtml)->vadjustment->value; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
705 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
|
706 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
707 bits = imhtml->bits; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
708 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
709 while (bits) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
710 bit = bits->data; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
711 chunks = bit->chunks; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
712 if (DRAW_IMG (bit)) { |
1461
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
713 if (chunks) { |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
714 line = chunks->data; |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
715 if ((line->x <= x + width) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
716 (line->y <= y + height) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
717 (x <= line->x + line->width) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
718 (y <= line->y + line->height)) |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
719 draw_img (imhtml, line); |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
720 } |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
721 } else if (bit->type == TYPE_SEP) { |
1461
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
722 if (chunks) { |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
723 line = chunks->data; |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
724 if ((line->x <= x + width) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
725 (line->y <= y + height) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
726 (x <= line->x + line->width) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
727 (y <= line->y + line->height)) |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
728 draw_line (imhtml, line); |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
729 |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
730 line = chunks->next->data; |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
731 if ((line->x <= x + width) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
732 (line->y <= y + height) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
733 (x <= line->x + line->width) && |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
734 (y <= line->y + line->height)) |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
735 draw_text (imhtml, line); |
9774a0a304c4
[gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1460
diff
changeset
|
736 } |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
737 } else { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
738 while (chunks) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
739 line = chunks->data; |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
740 if ((line->x <= x + width) && |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
741 (line->y <= y + height) && |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
742 (x <= line->x + line->width) && |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
743 (y <= line->y + line->height)) |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
744 draw_text (imhtml, line); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
745 chunks = g_list_next (chunks); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
746 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
747 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
748 bits = g_list_next (bits); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
749 } |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
750 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
751 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml)); |
1428 | 752 } |
753 | |
754 static void | |
755 gtk_imhtml_draw (GtkWidget *widget, | |
756 GdkRectangle *area) | |
757 { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
758 GtkIMHtml *imhtml; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
759 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
760 imhtml = GTK_IMHTML (widget); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
761 gtk_imhtml_draw_exposed (imhtml); |
1428 | 762 } |
763 | |
764 static void | |
765 gtk_imhtml_style_set (GtkWidget *widget, | |
766 GtkStyle *style) | |
767 { | |
768 GtkIMHtml *imhtml; | |
769 | |
770 g_return_if_fail (widget != NULL); | |
771 g_return_if_fail (GTK_IS_IMHTML (widget)); | |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
772 |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
773 if (GTK_WIDGET_CLASS (parent_class)->style_set) |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
774 (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, style); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
775 |
1428 | 776 if (!GTK_WIDGET_REALIZED (widget)) |
777 return; | |
778 | |
779 imhtml = GTK_IMHTML (widget); | |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
780 gtk_imhtml_draw_exposed (imhtml); |
1428 | 781 } |
782 | |
783 static gint | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
784 gtk_imhtml_expose_event (GtkWidget *widget, |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
785 GdkEventExpose *event) |
1428 | 786 { |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
787 GtkIMHtml *imhtml; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
788 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
789 g_return_val_if_fail (widget != NULL, FALSE); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
790 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
791 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
792 imhtml = GTK_IMHTML (widget); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
793 gtk_imhtml_draw_exposed (imhtml); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
794 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
795 return FALSE; |
1428 | 796 } |
797 | |
798 static void | |
799 gtk_imhtml_redraw_all (GtkIMHtml *imhtml) | |
800 { | |
801 GList *b; | |
802 GtkIMHtmlBit *bit; | |
803 GtkAdjustment *vadj; | |
804 gfloat oldvalue; | |
1527
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
805 gint oldy; |
1428 | 806 |
807 vadj = GTK_LAYOUT (imhtml)->vadjustment; | |
808 oldvalue = vadj->value / vadj->upper; | |
1527
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
809 oldy = imhtml->y; |
1428 | 810 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
811 gtk_layout_freeze (GTK_LAYOUT (imhtml)); |
1428 | 812 |
813 g_list_free (imhtml->line); | |
814 imhtml->line = NULL; | |
815 | |
816 while (imhtml->urls) { | |
817 g_free (imhtml->urls->data); | |
818 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data); | |
819 } | |
820 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
821 imhtml->x = 0; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
822 imhtml->y = TOP_BORDER; |
1428 | 823 imhtml->llheight = 0; |
824 imhtml->llascent = 0; | |
825 | |
2002
7c2457745344
[gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1998
diff
changeset
|
826 if (GTK_LAYOUT (imhtml)->yoffset < TOP_BORDER) |
7c2457745344
[gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1998
diff
changeset
|
827 gdk_window_clear_area (GTK_LAYOUT (imhtml)->bin_window, 0, 0, |
7c2457745344
[gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1998
diff
changeset
|
828 imhtml->xsize, TOP_BORDER - GTK_LAYOUT (imhtml)->yoffset); |
7c2457745344
[gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1998
diff
changeset
|
829 |
1428 | 830 b = imhtml->bits; |
831 while (b) { | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
832 bit = b->data; |
1428 | 833 b = g_list_next (b); |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
834 while (bit->chunks) { |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
835 struct line_info *li = bit->chunks->data; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
836 if (li->text) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
837 g_free (li->text); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
838 bit->chunks = g_list_remove (bit->chunks, li); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
839 g_free (li); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
840 } |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
841 gtk_imhtml_draw_bit (imhtml, bit); |
1428 | 842 } |
843 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
844 GTK_LAYOUT (imhtml)->height = imhtml->y; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
845 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
846 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
|
847 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
848 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y); |
1428 | 849 gtk_adjustment_set_value (vadj, vadj->upper * oldvalue); |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
850 |
1527
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
851 if (GTK_LAYOUT (imhtml)->bin_window && (imhtml->y < oldy)) { |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
852 GdkGC *gc; |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
853 GdkColormap *cmap; |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
854 |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
855 gc = gdk_gc_new (GTK_LAYOUT (imhtml)->bin_window); |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
856 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
857 |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
858 gdk_color_alloc (cmap, imhtml->default_bg_color); |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
859 gdk_gc_set_foreground (gc, imhtml->default_bg_color); |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
860 |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
861 gdk_draw_rectangle (GTK_LAYOUT (imhtml)->bin_window, gc, TRUE, |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
862 0, imhtml->y - GTK_LAYOUT (imhtml)->vadjustment->value, |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
863 GTK_WIDGET (imhtml)->allocation.width, |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
864 oldy - imhtml->y); |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
865 |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
866 gdk_gc_unref (gc); |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
867 } |
11977dd0fd29
[gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1524
diff
changeset
|
868 |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
869 gtk_layout_thaw (GTK_LAYOUT (imhtml)); |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
870 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml)); |
1428 | 871 } |
872 | |
873 static void | |
874 gtk_imhtml_size_allocate (GtkWidget *widget, | |
875 GtkAllocation *allocation) | |
876 { | |
877 GtkIMHtml *imhtml; | |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
878 GtkLayout *layout; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
879 gint new_xsize, new_ysize; |
1428 | 880 |
881 g_return_if_fail (widget != NULL); | |
882 g_return_if_fail (GTK_IS_IMHTML (widget)); | |
883 g_return_if_fail (allocation != NULL); | |
884 | |
885 imhtml = GTK_IMHTML (widget); | |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
886 layout = GTK_LAYOUT (widget); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
887 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
888 widget->allocation = *allocation; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
889 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
890 new_xsize = MAX (1, (gint) allocation->width - |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
891 (gint) (widget->style->klass->xthickness + BORDER_SIZE) * 2); |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
892 new_ysize = MAX (1, (gint) allocation->height - |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
893 (gint) (widget->style->klass->ythickness + BORDER_SIZE) * 2); |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
894 |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
895 if (GTK_WIDGET_REALIZED (widget)) { |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
896 gint x = widget->style->klass->xthickness + BORDER_SIZE; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
897 gint y = widget->style->klass->ythickness + BORDER_SIZE; |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
898 gdk_window_move_resize (widget->window, |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
899 allocation->x, allocation->y, |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
900 allocation->width, allocation->height); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
901 gdk_window_move_resize (layout->bin_window, |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
902 x, y, new_xsize, new_ysize); |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
903 } |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
904 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
905 layout->hadjustment->page_size = new_xsize; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
906 layout->hadjustment->page_increment = new_xsize / 2; |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
907 layout->hadjustment->lower = 0; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
908 layout->hadjustment->upper = imhtml->x; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
909 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
910 layout->vadjustment->page_size = new_ysize; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
911 layout->vadjustment->page_increment = new_ysize / 2; |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
912 layout->vadjustment->lower = 0; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
913 layout->vadjustment->upper = imhtml->y; |
1980
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 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed"); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
916 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed"); |
1428 | 917 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
918 if (new_xsize == imhtml->xsize) { |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
919 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y - new_ysize)) { |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
920 if (imhtml->y > new_ysize) |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
921 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
922 imhtml->y - new_ysize); |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
923 else |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
924 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, 0); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
925 } |
1428 | 926 return; |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
927 } |
1428 | 928 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
929 imhtml->xsize = new_xsize; |
1428 | 930 |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
931 if (GTK_WIDGET_REALIZED (widget)) |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
932 gtk_imhtml_redraw_all (imhtml); |
1428 | 933 } |
934 | |
935 static void | |
936 gtk_imhtml_select_none (GtkIMHtml *imhtml) | |
937 { | |
938 GList *bits; | |
939 GList *chunks; | |
940 GtkIMHtmlBit *bit; | |
941 struct line_info *chunk; | |
942 | |
943 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
944 | |
945 bits = imhtml->bits; | |
946 while (bits) { | |
947 bit = bits->data; | |
948 chunks = bit->chunks; | |
949 | |
950 while (chunks) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
951 chunk = chunks->data; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
952 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
953 if (chunk->selected) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
954 chunk->selected = FALSE; |
1449
91d84e2073de
[gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1447
diff
changeset
|
955 chunk->sel_start = chunk->text; |
91d84e2073de
[gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1447
diff
changeset
|
956 chunk->sel_end = NULL; |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
957 if (DRAW_IMG (bit)) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
958 draw_img (imhtml, chunk); |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
959 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk)) |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
960 draw_line (imhtml, chunk); |
2348
dd5f18429dd9
[gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2338
diff
changeset
|
961 else if (chunk->width) |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
962 draw_text (imhtml, chunk); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
963 } |
1428 | 964 |
965 chunks = g_list_next (chunks); | |
966 } | |
967 | |
968 bits = g_list_next (bits); | |
969 } | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
970 imhtml->sel_endchunk = NULL; |
1428 | 971 } |
972 | |
973 static gchar* | |
974 get_position (struct line_info *chunk, | |
975 gint x, | |
976 gboolean smileys) | |
977 { | |
978 gint width = x - chunk->x; | |
979 gchar *text; | |
980 gchar *pos; | |
981 guint total = 0; | |
982 | |
983 switch (chunk->bit->type) { | |
984 case TYPE_TEXT: | |
985 case TYPE_COMMENT: | |
986 text = chunk->text; | |
987 break; | |
988 case TYPE_SMILEY: | |
989 if (smileys) | |
990 return NULL; | |
991 else | |
992 text = chunk->text; | |
993 break; | |
994 default: | |
995 return NULL; | |
996 break; | |
997 } | |
998 | |
999 if (width <= 0) | |
1000 return text; | |
1001 | |
1002 for (pos = text; *pos != '\0'; pos++) { | |
1003 gint char_width = gdk_text_width (chunk->bit->font, pos, 1); | |
1004 if ((width > total) && (width <= total + char_width)) { | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
1005 if (width < total + (char_width / 2)) |
1428 | 1006 return pos; |
1007 else | |
1008 return ++pos; | |
1009 } | |
1010 total += char_width; | |
1011 } | |
1012 | |
1013 return pos; | |
1014 } | |
1015 | |
1016 static GString* | |
1017 append_to_sel (GString *string, | |
1018 struct line_info *chunk, | |
1019 gboolean smileys) | |
1020 { | |
1021 GString *new_string; | |
1022 gchar *buf; | |
1023 gchar *start; | |
1024 gint length; | |
1025 | |
1026 switch (chunk->bit->type) { | |
1027 case TYPE_TEXT: | |
1028 case TYPE_COMMENT: | |
1029 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start; | |
1030 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start; | |
1031 if (length <= 0) | |
1032 return string; | |
1033 buf = g_strndup (start, length); | |
1034 break; | |
1035 case TYPE_SMILEY: | |
1036 if (smileys) { | |
1037 start = (chunk->sel_start == NULL) ? chunk->bit->text : chunk->sel_start; | |
1038 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start; | |
1039 if (length <= 0) | |
1040 return string; | |
1041 buf = g_strndup (start, length); | |
1042 } else { | |
1043 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start; | |
1044 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start; | |
1045 if (length <= 0) | |
1046 return string; | |
1047 buf = g_strndup (start, length); | |
1048 } | |
1049 break; | |
1050 case TYPE_BR: | |
1051 buf = g_strdup ("\n"); | |
1052 break; | |
1053 default: | |
1054 return string; | |
1055 break; | |
1056 } | |
1057 | |
1058 new_string = g_string_append (string, buf); | |
1059 g_free (buf); | |
1060 | |
1061 return new_string; | |
1062 } | |
1063 | |
1064 #define COORDS_IN_CHUNK(xx, yy) (((xx) < chunk->x + chunk->width) && \ | |
1065 ((yy) < chunk->y + chunk->height)) | |
1066 | |
1067 static void | |
1068 gtk_imhtml_select_bits (GtkIMHtml *imhtml) | |
1069 { | |
1070 GList *bits; | |
1071 GList *chunks; | |
1072 GtkIMHtmlBit *bit; | |
1073 struct line_info *chunk; | |
1074 | |
1075 guint startx = imhtml->sel_startx, | |
1076 starty = imhtml->sel_starty, | |
1077 endx = imhtml->sel_endx, | |
1078 endy = imhtml->sel_endy; | |
1079 gchar *new_pos; | |
1080 gint selection = 0; | |
1081 gboolean smileys = imhtml->smileys; | |
1082 gboolean redraw = FALSE; | |
1083 gboolean got_start = FALSE; | |
1084 gboolean got_end = FALSE; | |
1085 | |
1086 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
1087 | |
1088 if (!imhtml->selection) | |
1089 return; | |
1090 | |
1091 if (imhtml->selected_text) { | |
1092 g_string_free (imhtml->selected_text, TRUE); | |
1093 imhtml->selected_text = g_string_new (""); | |
1094 } | |
1095 | |
1096 bits = imhtml->bits; | |
1097 while (bits) { | |
1098 bit = bits->data; | |
1099 chunks = bit->chunks; | |
1100 | |
1101 while (chunks) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1102 chunk = chunks->data; |
1428 | 1103 |
1104 switch (selection) { | |
1105 case 0: | |
1106 if (COORDS_IN_CHUNK (startx, starty)) { | |
1107 new_pos = get_position (chunk, startx, smileys); | |
1108 if ( !chunk->selected || | |
1109 (chunk->sel_start != new_pos) || | |
1110 (chunk->sel_end != NULL)) | |
1111 redraw = TRUE; | |
1112 chunk->selected = TRUE; | |
1113 chunk->sel_start = new_pos; | |
1114 chunk->sel_end = NULL; | |
1115 selection++; | |
1116 got_start = TRUE; | |
1117 } | |
1118 | |
1119 if (COORDS_IN_CHUNK (endx, endy)) { | |
1120 if (got_start) { | |
1121 new_pos = get_position (chunk, endx, smileys); | |
1122 if (chunk->sel_end != new_pos) | |
1123 redraw = TRUE; | |
1124 if (chunk->sel_start > new_pos) { | |
1125 chunk->sel_end = chunk->sel_start; | |
1126 chunk->sel_start = new_pos; | |
1127 } else | |
1128 chunk->sel_end = new_pos; | |
1129 selection = 2; | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1130 imhtml->sel_endchunk = chunk; |
1428 | 1131 got_end = TRUE; |
1132 } else { | |
1133 new_pos = get_position (chunk, endx, smileys); | |
1134 if ( !chunk->selected || | |
1135 (chunk->sel_start != new_pos) || | |
1136 (chunk->sel_end != NULL)) | |
1137 redraw = TRUE; | |
1138 chunk->selected = TRUE; | |
1139 chunk->sel_start = new_pos; | |
1140 chunk->sel_end = NULL; | |
1141 selection++; | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1142 imhtml->sel_endchunk = chunk; |
1428 | 1143 got_end = TRUE; |
1144 } | |
1145 } else if (!COORDS_IN_CHUNK (startx, starty) && !got_start) { | |
1146 if (chunk->selected) | |
1147 redraw = TRUE; | |
1148 chunk->selected = FALSE; | |
1149 chunk->sel_start = chunk->text; | |
1150 chunk->sel_end = NULL; | |
1151 } | |
1152 | |
1153 break; | |
1154 case 1: | |
1155 if (!got_start && COORDS_IN_CHUNK (startx, starty)) { | |
1156 new_pos = get_position (chunk, startx, smileys); | |
1157 if ( !chunk->selected || | |
1158 (chunk->sel_end != new_pos) || | |
1159 (chunk->sel_start != chunk->text)) | |
1160 redraw = TRUE; | |
1161 chunk->selected = TRUE; | |
1162 chunk->sel_start = chunk->text; | |
1163 chunk->sel_end = new_pos; | |
1164 selection++; | |
1165 got_start = TRUE; | |
1166 } else if (!got_end && COORDS_IN_CHUNK (endx, endy)) { | |
1167 new_pos = get_position (chunk, endx, smileys); | |
1168 if ( !chunk->selected || | |
1169 (chunk->sel_end != new_pos) || | |
1170 (chunk->sel_start != chunk->text)) | |
1171 redraw = TRUE; | |
1172 chunk->selected = TRUE; | |
1173 chunk->sel_start = chunk->text; | |
1174 chunk->sel_end = new_pos; | |
1175 selection++; | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1176 imhtml->sel_endchunk = chunk; |
1428 | 1177 got_end = TRUE; |
1178 } else { | |
1179 if ( !chunk->selected || | |
1449
91d84e2073de
[gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1447
diff
changeset
|
1180 (chunk->sel_end != NULL) || |
91d84e2073de
[gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1447
diff
changeset
|
1181 (chunk->sel_start != chunk->text)) |
1428 | 1182 redraw = TRUE; |
1183 chunk->selected = TRUE; | |
1184 chunk->sel_start = chunk->text; | |
1185 chunk->sel_end = NULL; | |
1186 } | |
1187 | |
1188 break; | |
1189 case 2: | |
1449
91d84e2073de
[gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1447
diff
changeset
|
1190 if (chunk->selected) |
1428 | 1191 redraw = TRUE; |
1192 chunk->selected = FALSE; | |
1193 chunk->sel_start = chunk->text; | |
1194 chunk->sel_end = NULL; | |
1195 break; | |
1196 } | |
1197 | |
1198 if (chunk->selected == TRUE) | |
1199 imhtml->selected_text = append_to_sel (imhtml->selected_text, | |
1200 chunk, smileys); | |
1201 | |
1202 if (redraw) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1203 if (DRAW_IMG (bit)) |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1204 draw_img (imhtml, chunk); |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
1205 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk)) |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
1206 draw_line (imhtml, chunk); |
2348
dd5f18429dd9
[gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2338
diff
changeset
|
1207 else if (chunk->width) |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1208 draw_text (imhtml, chunk); |
1428 | 1209 redraw = FALSE; |
1210 } | |
1211 | |
1212 chunks = g_list_next (chunks); | |
1213 } | |
1214 | |
1215 bits = g_list_next (bits); | |
1216 } | |
1217 } | |
1218 | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1219 static void |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1220 gtk_imhtml_select_in_chunk (GtkIMHtml *imhtml, |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1221 struct line_info *chunk) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1222 { |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1223 GtkIMHtmlBit *bit = chunk->bit; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1224 gchar *new_pos; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1225 guint endx = imhtml->sel_endx; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1226 guint startx = imhtml->sel_startx; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1227 guint starty = imhtml->sel_starty; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1228 gboolean smileys = imhtml->smileys; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1229 gboolean redraw = FALSE; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1230 |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1231 new_pos = get_position (chunk, endx, smileys); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1232 if ((starty < chunk->y) || |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1233 ((starty < chunk->y + chunk->height) && (startx < endx))) { |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1234 if (chunk->sel_end != new_pos) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1235 redraw = TRUE; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1236 chunk->sel_end = new_pos; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1237 } else { |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1238 if (chunk->sel_start != new_pos) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1239 redraw = TRUE; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1240 chunk->sel_start = new_pos; |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1241 } |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1242 |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1243 if (redraw) { |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1244 if (DRAW_IMG (bit)) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1245 draw_img (imhtml, chunk); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1246 else if ((bit->type == TYPE_SEP) && |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1247 (bit->chunks->data == chunk)) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1248 draw_line (imhtml, chunk); |
2348
dd5f18429dd9
[gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2338
diff
changeset
|
1249 else if (chunk->width) |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1250 draw_text (imhtml, chunk); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1251 } |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1252 } |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1253 |
1428 | 1254 static gint |
1255 scroll_timeout (GtkIMHtml *imhtml) | |
1256 { | |
1257 GdkEventMotion event; | |
1258 gint x, y; | |
1259 GdkModifierType mask; | |
1260 | |
1261 imhtml->scroll_timer = 0; | |
1262 | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
1263 gdk_window_get_pointer (GTK_LAYOUT (imhtml)->bin_window, &x, &y, &mask); |
1428 | 1264 |
1265 if (mask & GDK_BUTTON1_MASK) { | |
1266 event.is_hint = 0; | |
1267 event.x = x; | |
1268 event.y = y; | |
1269 event.state = mask; | |
1270 | |
1271 gtk_imhtml_motion_notify_event (GTK_WIDGET (imhtml), &event); | |
1272 } | |
1273 | |
1274 return FALSE; | |
1275 } | |
1276 | |
1277 static gint | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1278 gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1279 { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1280 GtkStyle *style; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1281 gint y, baseline_skip, gap; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1282 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1283 style = imhtml->tip_window->style; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1284 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1285 gap = (style->font->ascent + style->font->descent) / 4; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1286 if (gap < 2) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1287 gap = 2; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1288 baseline_skip = style->font->ascent + style->font->descent + gap; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1289 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1290 if (!imhtml->tip_bit) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1291 return FALSE; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1292 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
1293 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
|
1294 NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1295 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1296 y = style->font->ascent + 4; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1297 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
|
1298 imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->url); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1299 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1300 return FALSE; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1301 } |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1302 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1303 static gint |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1304 gtk_imhtml_tip (gpointer data) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1305 { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1306 GtkIMHtml *imhtml = data; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1307 GtkWidget *widget = GTK_WIDGET (imhtml); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1308 GtkStyle *style; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1309 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
|
1310 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1311 if (!imhtml->tip_bit || !GTK_WIDGET_DRAWABLE (widget)) { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1312 imhtml->tip_timer = 0; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1313 return FALSE; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1314 } |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1315 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1316 if (imhtml->tip_window) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1317 gtk_widget_destroy (imhtml->tip_window); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1318 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1319 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1320 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1321 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
|
1322 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1323 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "expose_event", |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1324 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml)); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1325 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "draw", |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1326 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml)); |
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 gtk_widget_ensure_style (imhtml->tip_window); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1329 style = imhtml->tip_window->style; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1330 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1331 scr_w = gdk_screen_width (); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1332 scr_h = gdk_screen_height (); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1333 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1334 gap = (style->font->ascent + style->font->descent) / 4; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1335 if (gap < 2) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1336 gap = 2; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1337 baseline_skip = style->font->ascent + style->font->descent + gap; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1338 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1339 w = 8 + gdk_string_width (style->font, imhtml->tip_bit->url); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1340 h = 8 - gap + baseline_skip; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1341 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1342 gdk_window_get_pointer (NULL, &x, &y, NULL); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1343 if (GTK_WIDGET_NO_WINDOW (widget)) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1344 y += widget->allocation.y; |
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 x -= ((w >> 1) + 4); |
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 if ((x + w) > scr_w) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1349 x -= (x + w) - scr_w; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1350 else if (x < 0) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1351 x = 0; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1352 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1353 if ((y + h + + 4) > scr_h) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1354 y = y - imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent; |
2071 | 1355 else |
1356 if (imhtml->tip_bit->font) | |
1357 y = y + imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent; | |
1358 else | |
1359 y = y + style->font->ascent + style->font->descent; | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1360 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1361 gtk_widget_set_usize (imhtml->tip_window, w, h); |
1955
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1362 gtk_widget_set_uposition (imhtml->tip_window, x, y); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1363 gtk_widget_show (imhtml->tip_window); |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1364 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1365 imhtml->tip_timer = 0; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1366 return FALSE; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1367 } |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1368 |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1369 static gint |
1428 | 1370 gtk_imhtml_motion_notify_event (GtkWidget *widget, |
1371 GdkEventMotion *event) | |
1372 { | |
1373 gint x, y; | |
1374 GdkModifierType state; | |
1375 GtkIMHtml *imhtml = GTK_IMHTML (widget); | |
1376 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment; | |
1377 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment; | |
1378 | |
1379 if (event->is_hint) | |
1380 gdk_window_get_pointer (event->window, &x, &y, &state); | |
1381 else { | |
1382 x = event->x + hadj->value; | |
1383 y = event->y + vadj->value; | |
1384 state = event->state; | |
1385 } | |
1386 | |
1387 if (state & GDK_BUTTON1_MASK) { | |
1388 gint diff; | |
1389 gint height = vadj->page_size; | |
1390 gint yy = y - vadj->value; | |
1391 | |
1392 if (((yy < 0) || (yy > height)) && | |
1393 (imhtml->scroll_timer == 0) && | |
1394 (vadj->upper > vadj->page_size)) { | |
1395 imhtml->scroll_timer = gtk_timeout_add (100, | |
1396 (GtkFunction) scroll_timeout, | |
1397 imhtml); | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
1398 diff = (yy < 0) ? (yy / 2) : ((yy - height) / 2); |
1428 | 1399 gtk_adjustment_set_value (vadj, |
2337
e3939d21c2f0
[gaim-migrate @ 2350]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2188
diff
changeset
|
1400 MIN (vadj->value + diff, vadj->upper - height)); |
1428 | 1401 } |
1402 | |
1403 if (imhtml->selection) { | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1404 struct line_info *chunk = imhtml->sel_endchunk; |
1428 | 1405 imhtml->sel_endx = MAX (x, 0); |
1406 imhtml->sel_endy = MAX (y, 0); | |
1515
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1407 if ((chunk == NULL) || |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1408 (x < chunk->x) || |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1409 (x > chunk->x + chunk->width) || |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1410 (y < chunk->y) || |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1411 (y > chunk->y + chunk->height)) |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1412 gtk_imhtml_select_bits (imhtml); |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1413 else |
206f995a33f3
[gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1482
diff
changeset
|
1414 gtk_imhtml_select_in_chunk (imhtml, chunk); |
1428 | 1415 } |
1416 } else { | |
1417 GList *urls = imhtml->urls; | |
1418 struct url_widget *uw; | |
1419 | |
1420 while (urls) { | |
1421 uw = (struct url_widget *) urls->data; | |
1422 if ((x > uw->x) && (x < uw->x + uw->width) && | |
1423 (y > uw->y) && (y < uw->y + uw->height)) { | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1424 if (imhtml->tip_bit != uw->bit) { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1425 imhtml->tip_bit = uw->bit; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1426 if (imhtml->tip_timer != 0) |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1427 gtk_timeout_remove (imhtml->tip_timer); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1428 if (imhtml->tip_window) { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1429 gtk_widget_destroy (imhtml->tip_window); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1430 imhtml->tip_window = NULL; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1431 } |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1432 imhtml->tip_timer = gtk_timeout_add (TOOLTIP_TIMEOUT, |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1433 gtk_imhtml_tip, |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1434 imhtml); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1435 } |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
1436 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, |
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
1437 imhtml->hand_cursor); |
1428 | 1438 return TRUE; |
1439 } | |
1440 urls = g_list_next (urls); | |
1441 } | |
1442 } | |
1443 | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1444 if (imhtml->tip_timer) { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1445 gtk_timeout_remove (imhtml->tip_timer); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1446 imhtml->tip_timer = 0; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1447 } |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1448 if (imhtml->tip_window) { |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1449 gtk_widget_destroy (imhtml->tip_window); |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1450 imhtml->tip_window = NULL; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1451 } |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1452 imhtml->tip_bit = NULL; |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1453 |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
1454 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor); |
1428 | 1455 |
1456 return TRUE; | |
1457 } | |
1458 | |
1459 static gint | |
1613
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1460 gtk_imhtml_leave_notify_event (GtkWidget *widget, |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1461 GdkEventCrossing *event) |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1462 { |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1463 GtkIMHtml *imhtml = GTK_IMHTML (widget); |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1464 |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1465 if (imhtml->tip_timer) { |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1466 gtk_timeout_remove (imhtml->tip_timer); |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1467 imhtml->tip_timer = 0; |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1468 } |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1469 if (imhtml->tip_window) { |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1470 gtk_widget_destroy (imhtml->tip_window); |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1471 imhtml->tip_window = NULL; |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1472 } |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1473 imhtml->tip_bit = NULL; |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1474 |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1475 return TRUE; |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1476 } |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1477 |
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1478 static gint |
1428 | 1479 gtk_imhtml_button_press_event (GtkWidget *widget, |
1480 GdkEventButton *event) | |
1481 { | |
1482 GtkIMHtml *imhtml = GTK_IMHTML (widget); | |
1483 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment; | |
1484 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment; | |
1485 gint x, y; | |
1486 | |
1487 if (event->button == 1) { | |
1488 x = event->x + hadj->value; | |
1489 y = event->y + vadj->value; | |
1490 | |
1491 imhtml->sel_startx = x; | |
1492 imhtml->sel_starty = y; | |
1493 imhtml->selection = TRUE; | |
1494 gtk_imhtml_select_none (imhtml); | |
1495 } | |
1496 | |
1497 return TRUE; | |
1498 } | |
1499 | |
1500 static gint | |
1501 gtk_imhtml_button_release_event (GtkWidget *widget, | |
1502 GdkEventButton *event) | |
1503 { | |
1504 GtkIMHtml *imhtml = GTK_IMHTML (widget); | |
1505 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment; | |
1506 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment; | |
1507 gint x, y; | |
1508 | |
1456
6650776468b3
[gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1454
diff
changeset
|
1509 x = event->x + hadj->value; |
6650776468b3
[gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1454
diff
changeset
|
1510 y = event->y + vadj->value; |
6650776468b3
[gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1454
diff
changeset
|
1511 |
1428 | 1512 if ((event->button == 1) && imhtml->selection) { |
1513 if ((x == imhtml->sel_startx) && (y == imhtml->sel_starty)) { | |
1514 imhtml->sel_startx = imhtml->sel_starty = 0; | |
1515 imhtml->selection = FALSE; | |
1516 gtk_imhtml_select_none (imhtml); | |
1517 } else { | |
1518 imhtml->sel_endx = MAX (x, 0); | |
1519 imhtml->sel_endy = MAX (y, 0); | |
1520 gtk_imhtml_select_bits (imhtml); | |
1521 } | |
1522 | |
1523 gtk_selection_owner_set (widget, GDK_SELECTION_PRIMARY, event->time); | |
1524 } | |
1525 | |
1547
7b50a08090a2
[gaim-migrate @ 1557]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1528
diff
changeset
|
1526 if ((event->button == 1) && (imhtml->sel_startx == 0)) { |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1527 GList *urls = imhtml->urls; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1528 struct url_widget *uw; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1529 |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1530 while (urls) { |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1531 uw = (struct url_widget *) urls->data; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1532 if ((x > uw->x) && (x < uw->x + uw->width) && |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1533 (y > uw->y) && (y < uw->y + uw->height)) { |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1534 gtk_signal_emit (GTK_OBJECT (imhtml), signals [URL_CLICKED], |
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
1535 uw->bit->url); |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1536 return TRUE; |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1537 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1538 urls = g_list_next (urls); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1539 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1540 } |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1541 |
1428 | 1542 return TRUE; |
1543 } | |
1544 | |
1545 static void | |
1546 gtk_imhtml_selection_get (GtkWidget *widget, | |
1547 GtkSelectionData *sel_data, | |
1548 guint sel_info, | |
1549 guint32 time) | |
1550 { | |
1551 GtkIMHtml *imhtml; | |
1552 gchar *string; | |
1553 gint length; | |
1554 | |
1555 g_return_if_fail (widget != NULL); | |
1556 g_return_if_fail (GTK_IS_IMHTML (widget)); | |
1557 g_return_if_fail (sel_data->selection == GDK_SELECTION_PRIMARY); | |
1558 | |
1559 imhtml = GTK_IMHTML (widget); | |
1560 | |
1561 g_return_if_fail (imhtml->selected_text != NULL); | |
1562 g_return_if_fail (imhtml->selected_text->str != NULL); | |
1563 | |
2188
98c434792ab7
[gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2140
diff
changeset
|
1564 if (imhtml->selected_text->len <= 0) |
98c434792ab7
[gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2140
diff
changeset
|
1565 return; |
98c434792ab7
[gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2140
diff
changeset
|
1566 |
98c434792ab7
[gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2140
diff
changeset
|
1567 string = g_strdup (imhtml->selected_text->str); |
98c434792ab7
[gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2140
diff
changeset
|
1568 length = strlen (string); |
1428 | 1569 |
1570 if (sel_info == TARGET_STRING) { | |
1571 gtk_selection_data_set (sel_data, | |
1572 GDK_SELECTION_TYPE_STRING, | |
1573 8 * sizeof (gchar), | |
1574 (guchar *) string, | |
1575 length); | |
1576 } else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT)) { | |
1577 guchar *text; | |
1578 GdkAtom encoding; | |
1579 gint format; | |
1580 gint new_length; | |
1581 | |
1582 gdk_string_to_compound_text (string, &encoding, &format, &text, &new_length); | |
1583 gtk_selection_data_set (sel_data, encoding, format, text, new_length); | |
1584 gdk_free_compound_text (text); | |
1585 } | |
1586 | |
2188
98c434792ab7
[gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2140
diff
changeset
|
1587 g_free (string); |
1428 | 1588 } |
1589 | |
1590 static gint | |
1591 gtk_imhtml_selection_clear_event (GtkWidget *widget, | |
1592 GdkEventSelection *event) | |
1593 { | |
1594 GtkIMHtml *imhtml; | |
1595 | |
1596 g_return_val_if_fail (widget != NULL, FALSE); | |
1597 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE); | |
1598 g_return_val_if_fail (event != NULL, FALSE); | |
1599 g_return_val_if_fail (event->selection == GDK_SELECTION_PRIMARY, TRUE); | |
1600 | |
1601 if (!gtk_selection_clear (widget, event)) | |
1602 return FALSE; | |
1603 | |
1604 imhtml = GTK_IMHTML (widget); | |
1605 | |
1606 gtk_imhtml_select_none (imhtml); | |
1607 | |
1608 return TRUE; | |
1609 } | |
1610 | |
1611 static void | |
1955
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1612 gtk_imhtml_adjustment_changed (GtkAdjustment *adjustment, |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1613 GtkIMHtml *imhtml) |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1614 { |
1980
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1615 GtkLayout *layout = GTK_LAYOUT (imhtml); |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1616 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1617 layout->xoffset = (gint) layout->hadjustment->value; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1618 layout->yoffset = (gint) layout->vadjustment->value; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1619 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1620 if (!GTK_WIDGET_MAPPED (imhtml) || !GTK_WIDGET_REALIZED (imhtml)) |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1621 return; |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1622 |
5b79252ea95c
[gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1979
diff
changeset
|
1623 if (layout->freeze_count) |
1955
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1624 return; |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1625 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
1626 if (layout->yoffset < TOP_BORDER) |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
1627 gdk_window_clear_area (layout->bin_window, 0, 0, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
1628 imhtml->xsize, TOP_BORDER - layout->yoffset); |
1961
0a3edeba05b6
[gaim-migrate @ 1971]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1955
diff
changeset
|
1629 |
1955
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1630 gtk_imhtml_draw_exposed (imhtml); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1631 } |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1632 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1633 static void |
1428 | 1634 gtk_imhtml_set_scroll_adjustments (GtkLayout *layout, |
1635 GtkAdjustment *hadj, | |
1636 GtkAdjustment *vadj) | |
1637 { | |
1955
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1638 gboolean need_adjust = FALSE; |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1639 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1640 g_return_if_fail (layout != NULL); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1641 g_return_if_fail (GTK_IS_IMHTML (layout)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1642 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1643 if (hadj) |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1644 g_return_if_fail (GTK_IS_ADJUSTMENT (hadj)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1645 else |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1646 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
|
1647 if (vadj) |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1648 g_return_if_fail (GTK_IS_ADJUSTMENT (vadj)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1649 else |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1650 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
|
1651 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1652 if (layout->hadjustment && (layout->hadjustment != hadj)) { |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1653 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->hadjustment), layout); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1654 gtk_object_unref (GTK_OBJECT (layout->hadjustment)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1655 } |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1656 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1657 if (layout->vadjustment && (layout->vadjustment != vadj)) { |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1658 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->vadjustment), layout); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1659 gtk_object_unref (GTK_OBJECT (layout->vadjustment)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1660 } |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1661 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1662 if (layout->hadjustment != hadj) { |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1663 layout->hadjustment = hadj; |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1664 gtk_object_ref (GTK_OBJECT (layout->hadjustment)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1665 gtk_object_sink (GTK_OBJECT (layout->hadjustment)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1666 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1667 gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed", |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1668 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1669 need_adjust = TRUE; |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1670 } |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1671 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1672 if (layout->vadjustment != vadj) { |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1673 layout->vadjustment = vadj; |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1674 gtk_object_ref (GTK_OBJECT (layout->vadjustment)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1675 gtk_object_sink (GTK_OBJECT (layout->vadjustment)); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1676 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1677 gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed", |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1678 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout); |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1679 need_adjust = TRUE; |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1680 } |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1681 |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1682 if (need_adjust) |
9ed99b8c5c9c
[gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1780
diff
changeset
|
1683 gtk_imhtml_adjustment_changed (NULL, GTK_IMHTML (layout)); |
1428 | 1684 } |
1685 | |
1686 static void | |
1687 gtk_imhtml_class_init (GtkIMHtmlClass *class) | |
1688 { | |
1689 GtkObjectClass *object_class; | |
1690 GtkWidgetClass *widget_class; | |
1691 GtkLayoutClass *layout_class; | |
1692 | |
1693 object_class = (GtkObjectClass*) class; | |
1694 widget_class = (GtkWidgetClass*) class; | |
1695 layout_class = (GtkLayoutClass*) class; | |
1696 | |
1697 parent_class = gtk_type_class (GTK_TYPE_LAYOUT); | |
1698 | |
1699 signals [URL_CLICKED] = | |
1700 gtk_signal_new ("url_clicked", | |
1701 GTK_RUN_FIRST, | |
1702 object_class->type, | |
1703 GTK_SIGNAL_OFFSET (GtkIMHtmlClass, url_clicked), | |
1704 gtk_marshal_NONE__POINTER, | |
1705 GTK_TYPE_NONE, 1, | |
1706 GTK_TYPE_POINTER); | |
1707 | |
1708 gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); | |
1709 | |
1710 object_class->destroy = gtk_imhtml_destroy; | |
1711 | |
1712 widget_class->realize = gtk_imhtml_realize; | |
1713 widget_class->draw = gtk_imhtml_draw; | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
1714 widget_class->draw_focus = gtk_imhtml_draw_focus; |
1428 | 1715 widget_class->style_set = gtk_imhtml_style_set; |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
1716 widget_class->expose_event = gtk_imhtml_expose_event; |
1428 | 1717 widget_class->size_allocate = gtk_imhtml_size_allocate; |
1718 widget_class->motion_notify_event = gtk_imhtml_motion_notify_event; | |
1613
35a13ece3a9c
[gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1582
diff
changeset
|
1719 widget_class->leave_notify_event = gtk_imhtml_leave_notify_event; |
1428 | 1720 widget_class->button_press_event = gtk_imhtml_button_press_event; |
1721 widget_class->button_release_event = gtk_imhtml_button_release_event; | |
1722 widget_class->selection_get = gtk_imhtml_selection_get; | |
1723 widget_class->selection_clear_event = gtk_imhtml_selection_clear_event; | |
1724 | |
1725 layout_class->set_scroll_adjustments = gtk_imhtml_set_scroll_adjustments; | |
1726 } | |
1727 | |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1728 static gchar** |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1729 get_font_names () |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1730 { |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1731 gint num_fonts = 0; |
2065
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1732 gchar **xfontnames; |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1733 static gchar **fonts = NULL; |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1734 gint i; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1735 |
2065
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1736 if (fonts) |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1737 return fonts; |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1738 |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1739 xfontnames = XListFonts (GDK_DISPLAY (), "-*", MAX_FONTS, &num_fonts); |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1740 |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1741 if (!num_fonts) { |
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1742 XFreeFontNames(xfontnames); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1743 return g_new0 (char *, 1); |
2065
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1744 } |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1745 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1746 fonts = g_new0 (char *, num_fonts + 1); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1747 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1748 for (i = 0; i < num_fonts; i++) { |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1749 gint countdown = 1, num_dashes = 1; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1750 const gchar *t1 = xfontnames [i]; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1751 const gchar *t2; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1752 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1753 while (*t1 && (countdown >= 0)) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1754 if (*t1++ == '-') |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1755 countdown--; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1756 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1757 for (t2 = t1; *t2; t2++) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1758 if (*t2 == '-' && --num_dashes == 0) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1759 break; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1760 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1761 fonts [i] = g_strndup (t1, (long) t2 - (long) t1); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1762 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1763 |
2065
391440022697
[gaim-migrate @ 2075]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
1764 XFreeFontNames(xfontnames); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1765 return fonts; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1766 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1767 |
1428 | 1768 static GdkFont* |
1769 gtk_imhtml_font_load (GtkIMHtml *imhtml, | |
1770 gchar *name, | |
1771 gboolean bold, | |
1772 gboolean italics, | |
1773 gint fontsize) | |
1774 { | |
1775 gchar buf [16 * 1024]; | |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1776 GdkFont *font = NULL; |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1777 XFontStruct *xfs; |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1778 static gchar **fontnames = NULL; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1779 gchar *choice = NULL; |
1428 | 1780 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
|
1781 gint i, j; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1782 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1783 if (!fontnames) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1784 fontnames = get_font_names (); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1785 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1786 if (name) { |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1787 gchar **choices = g_strsplit (name, ",", -1); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1788 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1789 for (i = 0; choices [i]; i++) { |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1790 for (j = 0; fontnames [j]; j++) |
2048
3366311426df
[gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2022
diff
changeset
|
1791 if (!g_strcasecmp (fontnames [j], choices [i])) |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1792 break; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1793 if (fontnames [j]) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1794 break; |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1795 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1796 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1797 if (choices [i]) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1798 choice = g_strdup (choices [i]); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1799 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1800 g_strfreev (choices); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1801 } else if (!bold && !italics && !fontsize && imhtml->default_font) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1802 return gdk_font_ref (imhtml->default_font); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1803 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1804 if (!choice) { |
2615
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1805 for (i = 0; fontnames [i]; i++) |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1806 if (!g_strcasecmp (fontnames [i], DEFAULT_FONT_NAME)) |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1807 break; |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1808 if (fontnames [i]) |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1809 choice = g_strdup (DEFAULT_FONT_NAME); |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1810 } |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1811 |
8b84198651c9
[gaim-migrate @ 2628]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2610
diff
changeset
|
1812 if (!choice) { |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1813 if (imhtml->default_font) |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1814 return gdk_font_ref (imhtml->default_font); |
2115
3ce77b547cf2
[gaim-migrate @ 2125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2075
diff
changeset
|
1815 return gdk_fontset_load ("-*-*-*-*-*-*-*-*-*-*-*-*-*-*,*"); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1816 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1817 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1818 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-%s", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1819 choice, |
1428 | 1820 bold ? "bold" : "medium", |
1821 italics ? 'i' : 'r', | |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1822 size, |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1823 getcharset()); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1824 font = gdk_font_load (buf); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1825 |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1826 if (!font && italics) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1827 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-%d-*-*-*-*-%s", |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1828 choice, |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1829 bold ? "bold" : "medium", |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1830 size, |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1831 getcharset()); |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1832 font = gdk_font_load (buf); |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1833 } |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1834 |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1835 if (!font) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1836 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-*-*-*-*-*-%s", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1837 choice, |
1428 | 1838 bold ? "bold" : "medium", |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1839 italics ? 'i' : 'r', |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1840 getcharset()); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1841 font = gdk_font_load (buf); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1842 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1843 |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1844 if (!font && italics) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1845 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-*-*-*-*-*-%s", |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1846 choice, |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1847 bold ? "bold" : "medium", |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1848 getcharset()); |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1849 font = gdk_font_load (buf); |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1850 } |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1851 |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1852 if (!font) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1853 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-%s", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1854 choice, |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1855 italics ? 'i' : 'r', |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1856 getcharset()); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1857 font = gdk_font_load (buf); |
1978
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 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1860 if (!font) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1861 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-%s", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1862 choice, |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1863 italics ? 'o' : '*', |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1864 getcharset()); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1865 font = gdk_font_load (buf); |
1428 | 1866 } |
1867 | |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1868 if (!font && italics) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1869 g_snprintf (buf, sizeof (buf), "-*-%s-*-*-*-*-*-*-*-*-*-*-%s", |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1870 choice, |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2365
diff
changeset
|
1871 getcharset()); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1872 font = gdk_font_load (buf); |
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 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1875 if (!font) { |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1876 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1877 choice, |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1878 bold ? "bold" : "medium", |
1428 | 1879 italics ? 'i' : 'r', |
1880 size); | |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1881 font = gdk_font_load (buf); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1882 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1883 |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1884 if (!font && italics) { |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1885 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-%d-*-*-*-*-*-*", |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1886 choice, |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1887 bold ? "bold" : "medium", |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1888 size); |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1889 font = gdk_font_load (buf); |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1890 } |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1891 |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1892 if (!font) { |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1893 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-*-*-*-*-*-*-*", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1894 choice, |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1895 bold ? "bold" : "medium", |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1896 italics ? 'i' : 'r'); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1897 font = gdk_font_load (buf); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1898 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1899 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1900 if (!font) { |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1901 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-*-*-*-*-*-*-*", |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1902 choice, |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1903 bold ? "bold" : "medium"); |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1904 font = gdk_font_load (buf); |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1905 } |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1906 |
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
1907 if (!font) { |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1908 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-*-*", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1909 choice, |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1910 italics ? 'i' : 'r'); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1911 font = gdk_font_load (buf); |
1428 | 1912 } |
1913 | |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1914 if (!font) { |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1915 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-*-*", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1916 choice, |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1917 italics ? 'o' : '*'); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1918 font = gdk_font_load (buf); |
1428 | 1919 } |
1920 | |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1921 if (!font && italics) { |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1922 g_snprintf (buf, sizeof (buf), "-*-%s-*-*-*-*-*-*-*-*-*-*-*-*", |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1923 choice); |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1924 font = gdk_font_load (buf); |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1925 } |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1926 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1927 g_free (choice); |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1928 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1929 if (!font && imhtml->default_font) |
1428 | 1930 return gdk_font_ref (imhtml->default_font); |
1931 | |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1932 xfs = font ? GDK_FONT_XFONT (font) : NULL; |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1933 if (xfs && (xfs->min_byte1 != 0 || xfs->max_byte1 != 0)) { |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1934 gchar *tmp_name; |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1935 |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1936 gdk_font_unref (font); |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1937 tmp_name = g_strconcat (buf, ",*", NULL); |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1938 font = gdk_fontset_load (tmp_name); |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1939 g_free (tmp_name); |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1940 } |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1941 |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1942 if (!font) |
2116
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1943 return gdk_fontset_load ("-*-*-*-*-*-*-*-*-*-*-*-*-*-*,*"); |
6402958c64c9
[gaim-migrate @ 2126]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2115
diff
changeset
|
1944 |
1978
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1945 |
a7bfa23e80a1
[gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1964
diff
changeset
|
1946 return font; |
1428 | 1947 } |
1948 | |
1949 static void | |
1950 gtk_imhtml_init (GtkIMHtml *imhtml) | |
1951 { | |
1952 static const GtkTargetEntry targets [] = { | |
1953 { "STRING", 0, TARGET_STRING }, | |
1954 { "TEXT", 0, TARGET_TEXT }, | |
1955 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT } | |
1956 }; | |
1957 | |
1958 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
1959 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
1960 | |
1961 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS); | |
1962 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3); | |
1963 } | |
1964 | |
1965 GtkType | |
1966 gtk_imhtml_get_type (void) | |
1967 { | |
1968 static GtkType imhtml_type = 0; | |
1969 | |
1970 if (!imhtml_type) { | |
1971 static const GtkTypeInfo imhtml_info = { | |
1972 "GtkIMHtml", | |
1973 sizeof (GtkIMHtml), | |
1974 sizeof (GtkIMHtmlClass), | |
1975 (GtkClassInitFunc) gtk_imhtml_class_init, | |
1976 (GtkObjectInitFunc) gtk_imhtml_init, | |
1977 NULL, | |
1978 NULL, | |
1979 NULL | |
1980 }; | |
1981 | |
1982 imhtml_type = gtk_type_unique (GTK_TYPE_LAYOUT, &imhtml_info); | |
1983 } | |
1984 | |
1985 return imhtml_type; | |
1986 } | |
1987 | |
1988 static void | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
1989 gtk_imhtml_init_smileys (GtkIMHtml *imhtml) |
1428 | 1990 { |
1991 g_return_if_fail (imhtml != NULL); | |
1992 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
1993 | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
1994 imhtml->smiley_data = gtk_smiley_tree_new (); |
1428 | 1995 |
1996 gtk_imhtml_associate_smiley (imhtml, ":)", smile_xpm); | |
1997 gtk_imhtml_associate_smiley (imhtml, ":-)", smile_xpm); | |
1998 | |
1999 gtk_imhtml_associate_smiley (imhtml, ":(", sad_xpm); | |
2000 gtk_imhtml_associate_smiley (imhtml, ":-(", sad_xpm); | |
2001 | |
2002 gtk_imhtml_associate_smiley (imhtml, ";)", wink_xpm); | |
2003 gtk_imhtml_associate_smiley (imhtml, ";-)", wink_xpm); | |
2004 | |
2005 gtk_imhtml_associate_smiley (imhtml, ":-p", tongue_xpm); | |
2006 gtk_imhtml_associate_smiley (imhtml, ":-P", tongue_xpm); | |
2007 | |
2008 gtk_imhtml_associate_smiley (imhtml, "=-O", scream_xpm); | |
2009 gtk_imhtml_associate_smiley (imhtml, ":-*", kiss_xpm); | |
2010 gtk_imhtml_associate_smiley (imhtml, ">:o", yell_xpm); | |
2011 gtk_imhtml_associate_smiley (imhtml, "8-)", smile8_xpm); | |
2012 gtk_imhtml_associate_smiley (imhtml, ":-$", moneymouth_xpm); | |
2013 gtk_imhtml_associate_smiley (imhtml, ":-!", burp_xpm); | |
2014 gtk_imhtml_associate_smiley (imhtml, ":-[", embarrassed_xpm); | |
2015 gtk_imhtml_associate_smiley (imhtml, ":'(", cry_xpm); | |
2016 | |
2017 gtk_imhtml_associate_smiley (imhtml, ":-/", think_xpm); | |
2018 gtk_imhtml_associate_smiley (imhtml, ":-\\", think_xpm); | |
2019 | |
2020 gtk_imhtml_associate_smiley (imhtml, ":-X", crossedlips_xpm); | |
2021 gtk_imhtml_associate_smiley (imhtml, ":-D", bigsmile_xpm); | |
2583
ce3df2c43f46
[gaim-migrate @ 2596]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2556
diff
changeset
|
2022 gtk_imhtml_associate_smiley (imhtml, ":-d", bigsmile_xpm); |
1428 | 2023 gtk_imhtml_associate_smiley (imhtml, "O:-)", angel_xpm); |
2024 } | |
2025 | |
2026 GtkWidget* | |
2027 gtk_imhtml_new (GtkAdjustment *hadj, | |
2028 GtkAdjustment *vadj) | |
2029 { | |
2030 GtkIMHtml *imhtml = gtk_type_new (GTK_TYPE_IMHTML); | |
2031 | |
2032 gtk_imhtml_set_adjustments (imhtml, hadj, vadj); | |
2033 | |
2034 imhtml->bits = NULL; | |
2035 imhtml->urls = NULL; | |
2036 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2037 imhtml->x = 0; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2038 imhtml->y = TOP_BORDER; |
1428 | 2039 imhtml->llheight = 0; |
2040 imhtml->llascent = 0; | |
2041 imhtml->line = NULL; | |
2042 | |
2043 imhtml->selected_text = g_string_new (""); | |
2044 imhtml->scroll_timer = 0; | |
2045 | |
2046 imhtml->img = NULL; | |
2047 | |
2048 imhtml->smileys = TRUE; | |
2049 imhtml->comments = FALSE; | |
2050 | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
2051 gtk_imhtml_init_smileys (imhtml); |
1428 | 2052 |
2053 return GTK_WIDGET (imhtml); | |
2054 } | |
2055 | |
2056 void | |
2057 gtk_imhtml_set_adjustments (GtkIMHtml *imhtml, | |
2058 GtkAdjustment *hadj, | |
2059 GtkAdjustment *vadj) | |
2060 { | |
2061 gtk_layout_set_hadjustment (GTK_LAYOUT (imhtml), hadj); | |
2062 gtk_layout_set_vadjustment (GTK_LAYOUT (imhtml), vadj); | |
2063 } | |
2064 | |
2065 void | |
2066 gtk_imhtml_set_defaults (GtkIMHtml *imhtml, | |
2067 GdkFont *font, | |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2068 GdkColor *fg_color, |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2069 GdkColor *bg_color) |
1428 | 2070 { |
2071 g_return_if_fail (imhtml != NULL); | |
2072 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
2073 | |
2074 if (font) { | |
2075 if (imhtml->default_font) | |
2076 gdk_font_unref (imhtml->default_font); | |
2077 imhtml->default_font = gdk_font_ref (font); | |
2078 } | |
2079 | |
2080 if (fg_color) { | |
2081 if (imhtml->default_fg_color) | |
2082 gdk_color_free (imhtml->default_fg_color); | |
2083 imhtml->default_fg_color = gdk_color_copy (fg_color); | |
2084 } | |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2085 |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2086 if (bg_color) { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2087 if (imhtml->default_bg_color) |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2088 gdk_color_free (imhtml->default_bg_color); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2089 imhtml->default_bg_color = gdk_color_copy (bg_color); |
1647
23b734cf1161
[gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1626
diff
changeset
|
2090 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
|
2091 } |
1428 | 2092 } |
2093 | |
2094 void | |
2095 gtk_imhtml_set_img_handler (GtkIMHtml *imhtml, | |
2096 GtkIMHtmlImage handler) | |
2097 { | |
2098 g_return_if_fail (imhtml != NULL); | |
2099 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
2100 | |
2101 imhtml->img = handler; | |
2102 } | |
2103 | |
2104 void | |
2105 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, | |
2106 gchar *text, | |
2107 gchar **xpm) | |
2108 { | |
2109 g_return_if_fail (imhtml != NULL); | |
2110 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
2111 g_return_if_fail (text != NULL); | |
2112 | |
2113 if (xpm == NULL) | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
2114 gtk_smiley_tree_remove (imhtml->smiley_data, text); |
1428 | 2115 else |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
2116 gtk_smiley_tree_insert (imhtml->smiley_data, text, xpm); |
1428 | 2117 } |
2118 | |
2119 static void | |
2120 new_line (GtkIMHtml *imhtml) | |
2121 { | |
2122 GList *last = g_list_last (imhtml->line); | |
2123 struct line_info *li; | |
2124 | |
2125 if (last) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2126 li = last->data; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2127 if (li->x + li->width != imhtml->xsize) |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2128 li->width = imhtml->xsize - li->x; |
1428 | 2129 } |
2130 | |
2131 last = imhtml->line; | |
2132 if (last) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2133 li = last->data; |
1428 | 2134 if (li->height < MIN_HEIGHT) { |
2135 while (last) { | |
2136 gint diff; | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2137 li = last->data; |
1428 | 2138 diff = MIN_HEIGHT - li->height; |
2139 li->height = MIN_HEIGHT; | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
2140 li->ascent += diff / 2; |
1428 | 2141 last = g_list_next (last); |
2142 } | |
2143 imhtml->llheight = MIN_HEIGHT; | |
2144 } | |
2145 } | |
2146 | |
2147 g_list_free (imhtml->line); | |
2148 imhtml->line = NULL; | |
2149 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2150 imhtml->x = 0; |
1428 | 2151 imhtml->y += imhtml->llheight; |
1462
1ac49082e099
[gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1461
diff
changeset
|
2152 imhtml->llheight = 0; |
1ac49082e099
[gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1461
diff
changeset
|
2153 imhtml->llascent = 0; |
1428 | 2154 } |
2155 | |
2156 static void | |
2157 backwards_update (GtkIMHtml *imhtml, | |
2158 GtkIMHtmlBit *bit, | |
2159 gint height, | |
2160 gint ascent) | |
2161 { | |
2162 gint diff; | |
2163 GList *ls = NULL; | |
2164 struct line_info *li; | |
2165 struct url_widget *uw; | |
2166 | |
2167 if (height > imhtml->llheight) { | |
2168 diff = height - imhtml->llheight; | |
2169 | |
2170 ls = imhtml->line; | |
2171 while (ls) { | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2172 li = ls->data; |
1428 | 2173 li->height += diff; |
2174 if (ascent) | |
2175 li->ascent = ascent; | |
2176 else | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
2177 li->ascent += diff / 2; |
1428 | 2178 ls = g_list_next (ls); |
2179 } | |
2180 | |
2181 ls = imhtml->urls; | |
2182 while (ls) { | |
2183 uw = ls->data; | |
2184 if (uw->y + diff > imhtml->y) | |
2185 uw->y += diff; | |
2186 ls = g_list_next (ls); | |
2187 } | |
2188 | |
2189 imhtml->llheight = height; | |
2190 if (ascent) | |
2191 imhtml->llascent = ascent; | |
2192 else | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
2193 imhtml->llascent += diff / 2; |
1428 | 2194 } |
2195 } | |
2196 | |
2197 static void | |
2198 add_text_renderer (GtkIMHtml *imhtml, | |
2199 GtkIMHtmlBit *bit, | |
2200 gchar *text) | |
2201 { | |
2202 struct line_info *li; | |
2203 struct url_widget *uw; | |
2204 gint width; | |
2205 | |
2206 if (text) | |
2207 width = gdk_string_width (bit->font, text); | |
2208 else | |
2209 width = 0; | |
2210 | |
2211 li = g_new0 (struct line_info, 1); | |
2212 li->x = imhtml->x; | |
2213 li->y = imhtml->y; | |
2214 li->width = width; | |
2215 li->height = imhtml->llheight; | |
2216 if (text) | |
2217 li->ascent = MAX (imhtml->llascent, bit->font->ascent); | |
2218 else | |
2219 li->ascent = 0; | |
2220 li->text = text; | |
2221 li->bit = bit; | |
2222 | |
2223 if (bit->url) { | |
2224 uw = g_new0 (struct url_widget, 1); | |
2225 uw->x = imhtml->x; | |
2226 uw->y = imhtml->y; | |
2227 uw->width = width; | |
2228 uw->height = imhtml->llheight; | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
2229 uw->bit = bit; |
1428 | 2230 imhtml->urls = g_list_append (imhtml->urls, uw); |
2231 } | |
2232 | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2233 bit->chunks = g_list_append (bit->chunks, li); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2234 imhtml->line = g_list_append (imhtml->line, li); |
1428 | 2235 } |
2236 | |
2237 static void | |
2238 add_img_renderer (GtkIMHtml *imhtml, | |
2239 GtkIMHtmlBit *bit) | |
2240 { | |
2241 struct line_info *li; | |
2242 struct url_widget *uw; | |
2243 gint width; | |
2244 | |
2245 gdk_window_get_size (bit->pm, &width, NULL); | |
2246 | |
2247 li = g_new0 (struct line_info, 1); | |
2248 li->x = imhtml->x; | |
2249 li->y = imhtml->y; | |
2250 li->width = width; | |
2251 li->height = imhtml->llheight; | |
2252 li->ascent = 0; | |
2253 li->bit = bit; | |
2254 | |
2255 if (bit->url) { | |
2256 uw = g_new0 (struct url_widget, 1); | |
2257 uw->x = imhtml->x; | |
2258 uw->y = imhtml->y; | |
2259 uw->width = width; | |
2260 uw->height = imhtml->llheight; | |
1574
7ad82fa9e6ce
[gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1547
diff
changeset
|
2261 uw->bit = bit; |
1428 | 2262 imhtml->urls = g_list_append (imhtml->urls, uw); |
2263 } | |
2264 | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2265 bit->chunks = g_list_append (bit->chunks, li); |
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
2266 imhtml->line = g_list_append (imhtml->line, li); |
1428 | 2267 |
2268 imhtml->x += width; | |
2269 } | |
2270 | |
2271 static void | |
2272 gtk_imhtml_draw_bit (GtkIMHtml *imhtml, | |
2273 GtkIMHtmlBit *bit) | |
2274 { | |
2275 gint width, height; | |
2276 | |
2277 g_return_if_fail (imhtml != NULL); | |
2278 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
2279 g_return_if_fail (bit != NULL); | |
2280 | |
2281 if ( (bit->type == TYPE_TEXT) || | |
2282 ((bit->type == TYPE_SMILEY) && !imhtml->smileys) || | |
2283 ((bit->type == TYPE_COMMENT) && imhtml->comments)) { | |
2284 gchar *copy = g_strdup (bit->text); | |
2285 gint pos = 0; | |
2286 gboolean seenspace = FALSE; | |
2287 gchar *tmp; | |
2288 | |
2289 height = bit->font->ascent + bit->font->descent; | |
2290 width = gdk_string_width (bit->font, bit->text); | |
2291 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2292 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize)) { |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2293 gint remain = imhtml->xsize - imhtml->x; |
1428 | 2294 while (gdk_text_width (bit->font, copy, pos) < remain) { |
2295 if (copy [pos] == ' ') | |
2296 seenspace = TRUE; | |
2297 pos++; | |
2298 } | |
2299 if (seenspace) { | |
2300 while (copy [pos - 1] != ' ') pos--; | |
2301 | |
2302 tmp = g_strndup (copy, pos); | |
2303 | |
2304 backwards_update (imhtml, bit, height, bit->font->ascent); | |
2305 add_text_renderer (imhtml, bit, tmp); | |
2306 } else | |
2307 pos = 0; | |
2308 seenspace = FALSE; | |
2309 new_line (imhtml); | |
2310 } | |
2311 | |
2312 backwards_update (imhtml, bit, height, bit->font->ascent); | |
2313 | |
2314 while (pos < strlen (bit->text)) { | |
2315 width = gdk_string_width (bit->font, copy + pos); | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2316 if (imhtml->x + width > imhtml->xsize) { |
1428 | 2317 gint newpos = 0; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2318 gint remain = imhtml->xsize - imhtml->x; |
1428 | 2319 while (gdk_text_width (bit->font, copy + pos, newpos) < remain) { |
2320 if (copy [pos + newpos] == ' ') | |
2321 seenspace = TRUE; | |
2322 newpos++; | |
2323 } | |
2324 | |
2325 if (seenspace) | |
2326 while (copy [pos + newpos - 1] != ' ') newpos--; | |
2327 | |
2328 if (newpos == 0) | |
2329 break; | |
2330 | |
2331 tmp = g_strndup (copy + pos, newpos); | |
2332 pos += newpos; | |
2333 | |
1462
1ac49082e099
[gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1461
diff
changeset
|
2334 backwards_update (imhtml, bit, height, bit->font->ascent); |
1428 | 2335 add_text_renderer (imhtml, bit, tmp); |
2336 | |
2337 seenspace = FALSE; | |
2338 new_line (imhtml); | |
2339 } else { | |
2340 tmp = g_strdup (copy + pos); | |
2341 | |
1462
1ac49082e099
[gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1461
diff
changeset
|
2342 backwards_update (imhtml, bit, height, bit->font->ascent); |
1428 | 2343 add_text_renderer (imhtml, bit, tmp); |
2344 | |
2345 pos = strlen (bit->text); | |
2346 | |
2347 imhtml->x += width; | |
2348 } | |
2349 } | |
2350 | |
2351 g_free (copy); | |
2352 } else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) { | |
2353 gdk_window_get_size (bit->pm, &width, &height); | |
2354 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2355 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize)) |
1428 | 2356 new_line (imhtml); |
1462
1ac49082e099
[gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1461
diff
changeset
|
2357 else |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2358 backwards_update (imhtml, bit, height, 0); |
1428 | 2359 |
2360 add_img_renderer (imhtml, bit); | |
2361 } else if (bit->type == TYPE_BR) { | |
2362 new_line (imhtml); | |
2363 add_text_renderer (imhtml, bit, NULL); | |
2364 } else if (bit->type == TYPE_SEP) { | |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2365 struct line_info *li; |
1462
1ac49082e099
[gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1461
diff
changeset
|
2366 if (imhtml->llheight) |
1428 | 2367 new_line (imhtml); |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2368 |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2369 li = g_new0 (struct line_info, 1); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2370 li->x = imhtml->x; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2371 li->y = imhtml->y; |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2372 li->width = imhtml->xsize; |
1454
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2373 li->height = HR_HEIGHT * 2; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2374 li->ascent = 0; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2375 li->text = NULL; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2376 li->bit = bit; |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2377 |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2378 bit->chunks = g_list_append (bit->chunks, li); |
637592eb8b24
[gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1453
diff
changeset
|
2379 |
1428 | 2380 imhtml->llheight = HR_HEIGHT * 2; |
2381 new_line (imhtml); | |
2382 add_text_renderer (imhtml, bit, NULL); | |
2383 } | |
2384 } | |
2385 | |
2386 void | |
2387 gtk_imhtml_show_smileys (GtkIMHtml *imhtml, | |
2388 gboolean show) | |
2389 { | |
2390 g_return_if_fail (imhtml != NULL); | |
2391 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
2392 | |
2393 imhtml->smileys = show; | |
2394 | |
2395 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml))) | |
2396 gtk_imhtml_redraw_all (imhtml); | |
2397 } | |
2398 | |
2399 void | |
2400 gtk_imhtml_show_comments (GtkIMHtml *imhtml, | |
2401 gboolean show) | |
2402 { | |
2403 g_return_if_fail (imhtml != NULL); | |
2404 g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
2405 | |
2406 imhtml->comments = show; | |
2407 | |
2408 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml))) | |
2409 gtk_imhtml_redraw_all (imhtml); | |
2410 } | |
2411 | |
2412 static GdkColor * | |
2413 gtk_imhtml_get_color (const gchar *color) | |
2414 { | |
2415 GdkColor c; | |
2416 | |
1453
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
2417 if (!gdk_color_parse (color, &c)) |
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
2418 return NULL; |
1428 | 2419 |
1449
91d84e2073de
[gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1447
diff
changeset
|
2420 return gdk_color_copy (&c); |
1428 | 2421 } |
2422 | |
2423 static gint | |
2424 gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
2425 const gchar *text) | |
2426 { | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
2427 return gtk_smiley_tree_lookup (imhtml->smiley_data, text); |
1428 | 2428 } |
2429 | |
2430 static GtkIMHtmlBit * | |
2431 gtk_imhtml_new_bit (GtkIMHtml *imhtml, | |
2432 gint type, | |
2433 gchar *text, | |
2434 gint bold, | |
2435 gint italics, | |
2436 gint underline, | |
2437 gint strike, | |
2438 FontDetail *font, | |
2439 GdkColor *bg, | |
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2440 gchar *url, |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2441 gint pre) |
1428 | 2442 { |
2443 GtkIMHtmlBit *bit = NULL; | |
2444 | |
2445 g_return_val_if_fail (imhtml != NULL, NULL); | |
2446 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL); | |
2447 | |
2448 if ((type == TYPE_TEXT) && ((text == NULL) || (strlen (text) == 0))) | |
2449 return NULL; | |
2450 | |
2451 bit = g_new0 (GtkIMHtmlBit, 1); | |
2452 bit->type = type; | |
2453 | |
2454 if ((text != NULL) && (strlen (text) != 0)) | |
2455 bit->text = g_strdup (text); | |
2456 | |
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2457 if ((font != NULL) || bold || italics || pre) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2458 if (font && (bold || italics || font->size || font->face || pre)) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2459 if (pre) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2460 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
|
2461 } else { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2462 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
|
2463 } |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2464 } else if (bold || italics || pre) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2465 if (pre) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2466 bit->font = gtk_imhtml_font_load (imhtml, "Courier", bold, italics, 0); |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2467 } else { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2468 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0); |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2469 } |
1428 | 2470 } |
2471 | |
2472 if (font && (type != TYPE_BR)) { | |
2473 if (font->fore != NULL) | |
2474 bit->fore = gdk_color_copy (font->fore); | |
2475 | |
2476 if (font->back != NULL) | |
2477 bit->back = gdk_color_copy (font->back); | |
2478 } | |
2479 } | |
2480 | |
2481 if (((bit->type == TYPE_TEXT) || (bit->type == TYPE_SMILEY) || (bit->type == TYPE_COMMENT)) && | |
2482 (bit->font == NULL)) | |
2483 bit->font = gdk_font_ref (imhtml->default_font); | |
2484 | |
2485 if (bg != NULL) | |
2486 bit->bg = gdk_color_copy (bg); | |
2487 | |
2488 bit->underline = underline; | |
2489 bit->strike = strike; | |
2490 | |
2491 if (url != NULL) | |
2492 bit->url = g_strdup (url); | |
2493 | |
2494 if (type == TYPE_SMILEY) { | |
2495 GdkColor *clr; | |
2496 | |
2497 if ((font != NULL) && (font->back != NULL)) | |
2498 clr = font->back; | |
2499 else | |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2500 clr = (bg != NULL) ? bg : imhtml->default_bg_color; |
1428 | 2501 |
2502 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window, | |
2503 &bit->bm, | |
2504 clr, | |
2349
60c716c32c40
[gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2348
diff
changeset
|
2505 gtk_smiley_tree_image (imhtml->smiley_data, text)); |
1428 | 2506 } |
2507 | |
2508 return bit; | |
2509 } | |
2510 | |
2511 #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
|
2512 fonts ? fonts->data : NULL, bg, url, pre) |
1428 | 2513 #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
|
2514 fonts ? fonts->data : NULL, bg, url, pre) |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2515 #define NEW_SEP_BIT gtk_imhtml_new_bit (imhtml, TYPE_SEP, NULL, 0, 0, 0, 0, NULL, bg, NULL, 0) |
1428 | 2516 #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
|
2517 fonts ? fonts->data : NULL, bg, NULL, 0) |
1428 | 2518 #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
|
2519 fonts ? fonts->data : NULL, bg, url, pre) |
1428 | 2520 |
2521 #define NEW_BIT(bit) { GtkIMHtmlBit *tmp = bit; if (tmp != NULL) \ | |
2522 newbits = g_list_append (newbits, tmp); } | |
2523 | |
2524 #define UPDATE_BG_COLORS \ | |
2525 { \ | |
2526 GdkColormap *cmap; \ | |
2527 GList *rev; \ | |
1476
721cd9b73704
[gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1473
diff
changeset
|
2528 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); \ |
1428 | 2529 rev = g_list_last (newbits); \ |
2530 while (rev) { \ | |
2531 GtkIMHtmlBit *bit = rev->data; \ | |
2532 if (bit->bg) \ | |
2533 gdk_color_free (bit->bg); \ | |
2534 bit->bg = gdk_color_copy (bg); \ | |
1582
4fcd012c0a6a
[gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1574
diff
changeset
|
2535 if (bit->type == TYPE_BR) \ |
4fcd012c0a6a
[gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1574
diff
changeset
|
2536 break; \ |
1428 | 2537 rev = g_list_previous (rev); \ |
2538 } \ | |
2539 if (!rev) { \ | |
2540 rev = g_list_last (imhtml->bits); \ | |
2541 while (rev) { \ | |
2542 GtkIMHtmlBit *bit = rev->data; \ | |
2543 if (bit->bg) \ | |
2544 gdk_color_free (bit->bg); \ | |
2545 bit->bg = gdk_color_copy (bg); \ | |
2546 gdk_color_alloc (cmap, bit->bg); \ | |
1582
4fcd012c0a6a
[gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1574
diff
changeset
|
2547 if (bit->type == TYPE_BR) \ |
4fcd012c0a6a
[gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1574
diff
changeset
|
2548 break; \ |
1428 | 2549 rev = g_list_previous (rev); \ |
2550 } \ | |
2551 } \ | |
2552 } | |
2553 | |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2554 static gboolean |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2555 is_amp_escape (const gchar *string, |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2556 gchar *replace, |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2557 gint *length) |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2558 { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2559 g_return_val_if_fail (string != NULL, FALSE); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2560 g_return_val_if_fail (replace != NULL, FALSE); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2561 g_return_val_if_fail (length != NULL, FALSE); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2562 |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2563 if (!g_strncasecmp (string, "&", 5)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2564 *replace = '&'; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2565 *length = 5; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2566 } else if (!g_strncasecmp (string, "<", 4)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2567 *replace = '<'; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2568 *length = 4; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2569 } else if (!g_strncasecmp (string, ">", 4)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2570 *replace = '>'; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2571 *length = 4; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2572 } else if (!g_strncasecmp (string, " ", 6)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2573 *replace = ' '; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2574 *length = 6; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2575 } else if (!g_strncasecmp (string, "©", 6)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2576 *replace = '©'; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2577 *length = 6; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2578 } else if (!g_strncasecmp (string, """, 6)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2579 *replace = '\"'; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2580 *length = 6; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2581 } else if (!g_strncasecmp (string, "®", 5)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2582 *replace = '®'; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2583 *length = 5; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2584 } else if (*(string + 1) == '#') { |
2022
199ba82faacb
[gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2002
diff
changeset
|
2585 guint pound = 0; |
199ba82faacb
[gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2002
diff
changeset
|
2586 if (sscanf (string, "&#%u;", £) == 1) { |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2587 if (*(string + 3 + (gint)log10 (pound)) != ';') |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2588 return FALSE; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2589 *replace = (gchar)pound; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2590 *length = 2; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2591 while (isdigit ((gint) string [*length])) (*length)++; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2592 if (string [*length] == ';') (*length)++; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2593 } else { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2594 return FALSE; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2595 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2596 } else { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2597 return FALSE; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2598 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2599 |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2600 return TRUE; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2601 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2602 |
1428 | 2603 GString* |
2604 gtk_imhtml_append_text (GtkIMHtml *imhtml, | |
2605 const gchar *text, | |
2606 GtkIMHtmlOptions options) | |
2607 { | |
2608 const gchar *c; | |
2609 gboolean intag = FALSE; | |
1703
acce65ffdc80
[gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1691
diff
changeset
|
2610 gint tagquote = 0; |
1428 | 2611 gboolean incomment = FALSE; |
2612 gchar *ws; | |
2613 gchar *tag; | |
2614 gint wpos = 0; | |
2615 gint tpos = 0; | |
2616 int smilelen; | |
2617 GList *newbits = NULL; | |
2618 | |
2619 guint bold = 0, | |
2620 italics = 0, | |
2621 underline = 0, | |
2622 strike = 0, | |
2623 sub = 0, | |
2624 sup = 0, | |
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2625 title = 0, |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2626 pre = 0; |
1428 | 2627 GSList *fonts = NULL; |
2628 GdkColor *bg = NULL; | |
2629 gchar *url = NULL; | |
2630 | |
2631 GtkAdjustment *vadj; | |
2632 gboolean scrolldown = TRUE; | |
2633 | |
2634 GString *retval = NULL; | |
2635 | |
2636 g_return_val_if_fail (imhtml != NULL, NULL); | |
2637 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL); | |
2638 g_return_val_if_fail (text != NULL, NULL); | |
2639 | |
2640 if (options & GTK_IMHTML_RETURN_LOG) | |
2641 retval = g_string_new (""); | |
2642 | |
2643 vadj = GTK_LAYOUT (imhtml)->vadjustment; | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
2644 if ((vadj->value < imhtml->y - GTK_WIDGET (imhtml)->allocation.height) && |
1428 | 2645 (vadj->upper >= GTK_WIDGET (imhtml)->allocation.height)) |
2646 scrolldown = FALSE; | |
2647 | |
2648 c = text; | |
2649 ws = g_malloc (strlen (text) + 1); | |
2650 tag = g_malloc (strlen (text) + 1); | |
2651 | |
2652 ws [0] = '\0'; | |
2653 | |
2654 while (*c) { | |
2655 if (*c == '<') { | |
1703
acce65ffdc80
[gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1691
diff
changeset
|
2656 if (intag && (tagquote != 1)) { |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2657 char *d; |
1428 | 2658 tag [tpos] = 0; |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2659 d = tag; |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2660 while (*d) { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2661 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2662 ws [wpos] = 0; |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2663 wpos = 0; |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2664 NEW_BIT (NEW_TEXT_BIT); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2665 g_snprintf (ws, smilelen + 1, "%s", d); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2666 NEW_BIT (NEW_SMILEY_BIT); |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2667 d += smilelen; |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2668 } else if (*d == '&') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2669 gchar replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2670 gint length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2671 if (is_amp_escape (d, &replace, &length)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2672 ws [wpos++] = replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2673 d += length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2674 } else { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2675 ws [wpos++] = *d++; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2676 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2677 } else if (*d == '\n') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2678 if (!(options & GTK_IMHTML_NO_NEWLINE)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2679 ws [wpos] = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2680 wpos = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2681 NEW_BIT (NEW_TEXT_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2682 NEW_BIT (NEW_BR_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2683 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
2684 d++; |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2685 } else { |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2686 ws [wpos++] = *d++; |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2687 } |
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
2688 } |
1428 | 2689 tpos = 0; |
2690 } | |
2691 | |
2692 if (incomment) { | |
2693 ws [wpos++] = *c++; | |
2694 continue; | |
2695 } | |
2696 | |
2697 if (!g_strncasecmp (c, "<!--", strlen ("<!--"))) { | |
2698 if (!(options & GTK_IMHTML_NO_COMMENTS)) { | |
2699 ws [wpos] = 0; | |
2700 wpos = 0; | |
2701 tag [tpos] = 0; | |
2702 strcat (tag, ws); | |
2703 incomment = TRUE; | |
2704 intag = FALSE; | |
2705 } | |
2706 ws [wpos++] = *c++; | |
2707 ws [wpos++] = *c++; | |
2708 ws [wpos++] = *c++; | |
2709 ws [wpos++] = *c++; | |
2710 continue; | |
2711 } | |
2712 | |
2713 tag [tpos++] = *c++; | |
2714 intag = TRUE; | |
1703
acce65ffdc80
[gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1691
diff
changeset
|
2715 tagquote = 0; |
1428 | 2716 } else if (incomment && (*c == '-') && !g_strncasecmp (c, "-->", strlen ("-->"))) { |
2717 gchar *tmp; | |
2718 ws [wpos] = 0; | |
2719 wpos = 0; | |
2720 tmp = g_strdup (ws); | |
2721 ws [wpos] = 0; | |
2722 strcat (ws, tag); | |
2723 NEW_BIT (NEW_TEXT_BIT); | |
2724 ws [wpos] = 0; | |
2725 strcat (ws, tmp + strlen ("<!--")); | |
2726 g_free (tmp); | |
2727 NEW_BIT (NEW_COMMENT_BIT); | |
2728 incomment = FALSE; | |
2729 c += strlen ("-->"); | |
1703
acce65ffdc80
[gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1691
diff
changeset
|
2730 } else if (*c == '>' && intag && (tagquote != 1)) { |
1428 | 2731 gboolean got_tag = FALSE; |
2732 tag [tpos++] = *c++; | |
2733 tag [tpos] = 0; | |
2734 ws [wpos] = 0; | |
2735 | |
2736 if (!g_strcasecmp (tag, "<B>") || !g_strcasecmp (tag, "<BOLD>")) { | |
2737 got_tag = TRUE; | |
2738 NEW_BIT (NEW_TEXT_BIT); | |
2739 bold++; | |
2740 } else if (!g_strcasecmp (tag, "</B>") || !g_strcasecmp (tag, "</BOLD>")) { | |
2741 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2742 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2743 if (bold) { |
2744 bold--; | |
2745 } | |
2746 } else if (!g_strcasecmp (tag, "<I>") || !g_strcasecmp (tag, "<ITALIC>")) { | |
2747 got_tag = TRUE; | |
2748 NEW_BIT (NEW_TEXT_BIT); | |
2749 italics++; | |
2750 } else if (!g_strcasecmp (tag, "</I>") || !g_strcasecmp (tag, "</ITALIC>")) { | |
2751 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2752 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2753 if (italics) { |
2754 italics--; | |
2755 } | |
2756 } else if (!g_strcasecmp (tag, "<U>") || !g_strcasecmp (tag, "<UNDERLINE>")) { | |
2757 got_tag = TRUE; | |
2758 NEW_BIT (NEW_TEXT_BIT); | |
2759 underline++; | |
2760 } else if (!g_strcasecmp (tag, "</U>") || !g_strcasecmp (tag, "</UNDERLINE>")) { | |
2761 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2762 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2763 if (underline) { |
2764 underline--; | |
2765 } | |
2766 } else if (!g_strcasecmp (tag, "<S>") || !g_strcasecmp (tag, "<STRIKE>")) { | |
2767 got_tag = TRUE; | |
2768 NEW_BIT (NEW_TEXT_BIT); | |
2769 strike++; | |
2770 } else if (!g_strcasecmp (tag, "</S>") || !g_strcasecmp (tag, "</STRIKE>")) { | |
2771 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2772 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2773 if (strike) { |
2774 strike--; | |
2775 } | |
2776 } else if (!g_strcasecmp (tag, "<SUB>")) { | |
2777 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2778 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2779 sub++; |
2780 } else if (!g_strcasecmp (tag, "</SUB>")) { | |
2781 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2782 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2783 if (sub) { |
2784 sub--; | |
2785 } | |
2786 } else if (!g_strcasecmp (tag, "<SUP>")) { | |
2787 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2788 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2789 sup++; |
2790 } else if (!g_strcasecmp (tag, "</SUP>")) { | |
2791 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2792 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2793 if (sup) { |
2794 sup--; | |
2795 } | |
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2796 } else if (!g_strcasecmp (tag, "<PRE>")) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2797 got_tag = TRUE; |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2798 NEW_BIT (NEW_TEXT_BIT); |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2799 pre++; |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2800 } else if (!g_strcasecmp (tag, "</PRE>")) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2801 got_tag = TRUE; |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2802 NEW_BIT (NEW_TEXT_BIT); |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2803 if (pre) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2804 pre--; |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
2805 } |
1428 | 2806 } else if (!g_strcasecmp (tag, "<TITLE>")) { |
2807 if (options & GTK_IMHTML_NO_TITLE) { | |
2808 got_tag = TRUE; | |
1626
59c7e7831ccd
[gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1613
diff
changeset
|
2809 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2810 title++; |
2811 } else { | |
2812 intag = FALSE; | |
2813 tpos = 0; | |
2814 continue; | |
2815 } | |
2816 } else if (!g_strcasecmp (tag, "</TITLE>")) { | |
2817 if (title) { | |
2818 got_tag = TRUE; | |
2819 wpos = 0; | |
2820 ws [wpos] = '\0'; | |
2821 title--; | |
2822 } else { | |
2823 intag = FALSE; | |
2824 tpos = 0; | |
2825 continue; | |
2826 } | |
2827 } else if (!g_strcasecmp (tag, "<BR>")) { | |
2828 got_tag = TRUE; | |
2829 NEW_BIT (NEW_TEXT_BIT); | |
2830 NEW_BIT (NEW_BR_BIT); | |
2831 } else if (!g_strcasecmp (tag, "<HR>") || | |
2832 !g_strncasecmp (tag, "<HR ", strlen ("<HR "))) { | |
2833 got_tag = TRUE; | |
2834 NEW_BIT (NEW_TEXT_BIT); | |
2835 NEW_BIT (NEW_SEP_BIT); | |
2836 } else if (!g_strncasecmp (tag, "<FONT ", strlen ("<FONT "))) { | |
2837 gchar *t, *e, *a, *value; | |
2838 FontDetail *font = NULL; | |
2839 GdkColor *clr; | |
2840 gint saw; | |
2841 gint i; | |
2842 | |
2843 t = tag + strlen ("<FONT "); | |
2844 | |
2845 while (*t != '\0') { | |
2846 value = NULL; | |
2847 saw = 0; | |
2848 | |
2849 while (g_strncasecmp (t, "COLOR=", strlen ("COLOR=")) | |
2850 && g_strncasecmp (t, "BACK=", strlen ("BACK=")) | |
2851 && g_strncasecmp (t, "FACE=", strlen ("FACE=")) | |
2852 && g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) { | |
2853 gboolean quote = FALSE; | |
2854 if (*t == '\0') break; | |
2855 while (*t && !((*t == ' ') && !quote)) { | |
2856 if (*t == '\"') | |
2857 quote = ! quote; | |
2858 t++; | |
2859 } | |
2860 while (*t && (*t == ' ')) t++; | |
2861 } | |
2862 | |
2863 if (!g_strncasecmp (t, "COLOR=", strlen ("COLOR="))) { | |
2864 t += strlen ("COLOR="); | |
2865 saw = 1; | |
2866 } else if (!g_strncasecmp (t, "BACK=", strlen ("BACK="))) { | |
2867 t += strlen ("BACK="); | |
2868 saw = 2; | |
2869 } else if (!g_strncasecmp (t, "FACE=", strlen ("FACE="))) { | |
2870 t += strlen ("FACE="); | |
2871 saw = 3; | |
2872 } else if (!g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) { | |
2873 t += strlen ("SIZE="); | |
2874 saw = 4; | |
2875 } | |
2876 | |
2877 if (!saw) | |
2878 continue; | |
2879 | |
2880 if ((*t == '\"') || (*t == '\'')) { | |
2881 e = a = ++t; | |
2882 while (*e && (*e != *(t - 1))) e++; | |
2883 if (*e != '\0') { | |
2884 *e = '\0'; | |
2885 t = e + 1; | |
2886 value = g_strdup (a); | |
2887 } else { | |
2888 *t = '\0'; | |
2889 } | |
2890 } else { | |
2891 e = a = t; | |
2892 while (*e && !isspace ((gint) *e)) e++; | |
2893 if (*e == '\0') e--; | |
2894 *e = '\0'; | |
2895 t = e + 1; | |
2896 value = g_strdup (a); | |
2897 } | |
2898 | |
2899 if (value == NULL) | |
2900 continue; | |
2901 | |
2902 if (font == NULL) | |
2903 font = g_new0 (FontDetail, 1); | |
2904 | |
2905 switch (saw) { | |
2906 case 1: | |
2907 clr = gtk_imhtml_get_color (value); | |
2908 if (clr != NULL) { | |
2909 if ( (font->fore == NULL) && | |
2910 !(options & GTK_IMHTML_NO_COLOURS)) | |
2911 font->fore = clr; | |
2912 } | |
2913 break; | |
2914 case 2: | |
2915 clr = gtk_imhtml_get_color (value); | |
2916 if (clr != NULL) { | |
2917 if ( (font->back == NULL) && | |
2918 !(options & GTK_IMHTML_NO_COLOURS)) | |
2919 font->back = clr; | |
2920 } | |
2921 break; | |
2922 case 3: | |
2923 if ( (font->face == NULL) && | |
2924 !(options & GTK_IMHTML_NO_FONTS)) | |
2925 font->face = g_strdup (value); | |
2926 break; | |
2927 case 4: | |
2928 if ((font->size != 0) || | |
2929 (options & GTK_IMHTML_NO_SIZES)) | |
2930 break; | |
2931 | |
2932 if (isdigit ((gint) value [0])) { | |
2933 for (i = 0; i < strlen (value); i++) | |
2934 if (!isdigit ((gint) value [i])) | |
2935 break; | |
2936 if (i != strlen (value)) | |
2937 break; | |
2938 | |
2939 sscanf (value, "%hd", &font->size); | |
2940 break; | |
2941 } | |
2942 | |
2943 if ((value [0] == '+') && (value [1] != '\0')) { | |
2944 for (i = 1; i < strlen (value); i++) | |
2945 if (!isdigit ((gint) value [i])) | |
2946 break; | |
2947 if (i != strlen (value)) | |
2948 break; | |
2949 | |
2950 sscanf (value + 1, "%hd", &font->size); | |
2951 font->size += 3; | |
2952 break; | |
2953 } | |
2954 | |
2955 if ((value [0] == '-') && (value [1] != '\0')) { | |
2956 for (i = 1; i < strlen (value); i++) | |
2957 if (!isdigit ((gint) value [i])) | |
2958 break; | |
2959 if (i != strlen (value)) | |
2960 break; | |
2961 | |
2962 sscanf (value + 1, "%hd", &font->size); | |
2963 font->size = MIN (font->size, 2); | |
2964 font->size = 3 - font->size; | |
2965 break; | |
2966 } | |
2967 | |
2968 break; | |
2969 } | |
2970 | |
2971 g_free (value); | |
2972 } | |
2973 | |
1738
bcd7f80f0086
[gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1703
diff
changeset
|
2974 if (!font || !(font->size || font->face || font->fore || font->back)) { |
2622
733471f39ac9
[gaim-migrate @ 2635]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2621
diff
changeset
|
2975 g_free (font); |
1428 | 2976 intag = FALSE; |
2977 tpos = 0; | |
2978 continue; | |
2979 } | |
2980 | |
1738
bcd7f80f0086
[gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1703
diff
changeset
|
2981 NEW_BIT (NEW_TEXT_BIT); |
1428 | 2982 |
2983 if (fonts) { | |
2984 FontDetail *oldfont = fonts->data; | |
2985 if (!font->size) | |
2986 font->size = oldfont->size; | |
2987 if (!font->face) | |
2988 font->face = g_strdup (oldfont->face); | |
2989 if (!font->fore && oldfont->fore) | |
2990 font->fore = gdk_color_copy (oldfont->fore); | |
2991 if (!font->back && oldfont->back) | |
2992 font->back = gdk_color_copy (oldfont->back); | |
2993 } else { | |
2994 if (!font->size) | |
2995 font->size = 3; | |
2996 if (!font->face) | |
2140
66a84ff0445a
[gaim-migrate @ 2150]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2116
diff
changeset
|
2997 font->face = g_strdup (DEFAULT_FONT_NAME); |
1428 | 2998 } |
2999 | |
3000 fonts = g_slist_prepend (fonts, font); | |
3001 got_tag = TRUE; | |
3002 } else if (!g_strcasecmp (tag, "</FONT>")) { | |
3003 FontDetail *font; | |
3004 | |
3005 if (fonts) { | |
3006 got_tag = TRUE; | |
3007 NEW_BIT (NEW_TEXT_BIT); | |
3008 font = fonts->data; | |
3009 fonts = g_slist_remove (fonts, font); | |
3010 g_free (font->face); | |
3011 if (font->fore) | |
3012 gdk_color_free (font->fore); | |
3013 if (font->back) | |
3014 gdk_color_free (font->back); | |
3015 g_free (font); | |
3016 } else { | |
3017 intag = FALSE; | |
3018 tpos = 0; | |
3019 continue; | |
3020 } | |
3021 } else if (!g_strncasecmp (tag, "<BODY ", strlen ("<BODY "))) { | |
3022 gchar *t, *e, *color = NULL; | |
3023 GdkColor *tmp; | |
3024 | |
3025 got_tag = TRUE; | |
3026 | |
3027 if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
3028 t = tag + strlen ("<BODY"); | |
3029 do { | |
3030 gboolean quote = FALSE; | |
3031 if (*t == '\0') break; | |
3032 while (*t && !((*t == ' ') && !quote)) { | |
3033 if (*t == '\"') | |
3034 quote = ! quote; | |
3035 t++; | |
3036 } | |
3037 while (*t && (*t == ' ')) t++; | |
3038 } while (g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR="))); | |
3039 | |
3040 if (!g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR="))) { | |
3041 t += strlen ("BGCOLOR="); | |
3042 if ((*t == '\"') || (*t == '\'')) { | |
3043 e = ++t; | |
3044 while (*e && (*e != *(t - 1))) e++; | |
3045 if (*e != '\0') { | |
3046 *e = '\0'; | |
3047 color = g_strdup (t); | |
3048 } | |
3049 } else { | |
3050 e = t; | |
3051 while (*e && !isspace ((gint) *e)) e++; | |
3052 if (*e == '\0') e--; | |
3053 *e = '\0'; | |
3054 color = g_strdup (t); | |
3055 } | |
3056 | |
3057 if (color != NULL) { | |
3058 tmp = gtk_imhtml_get_color (color); | |
3059 g_free (color); | |
3060 if (tmp != NULL) { | |
3061 NEW_BIT (NEW_TEXT_BIT); | |
3062 bg = tmp; | |
3063 UPDATE_BG_COLORS; | |
3064 } | |
3065 } | |
3066 } | |
3067 } | |
3068 } else if (!g_strncasecmp (tag, "<A ", strlen ("<A "))) { | |
3069 gchar *t, *e; | |
3070 | |
3071 got_tag = TRUE; | |
3072 NEW_BIT (NEW_TEXT_BIT); | |
3073 | |
3074 if (url != NULL) | |
3075 g_free (url); | |
3076 url = NULL; | |
3077 | |
3078 t = tag + strlen ("<A"); | |
3079 do { | |
3080 gboolean quote = FALSE; | |
3081 if (*t == '\0') break; | |
3082 while (*t && !((*t == ' ') && !quote)) { | |
3083 if (*t == '\"') | |
3084 quote = ! quote; | |
3085 t++; | |
3086 } | |
3087 while (*t && (*t == ' ')) t++; | |
3088 } while (g_strncasecmp (t, "HREF=", strlen ("HREF="))); | |
3089 | |
3090 if (!g_strncasecmp (t, "HREF=", strlen ("HREF="))) { | |
3091 t += strlen ("HREF="); | |
3092 if ((*t == '\"') || (*t == '\'')) { | |
3093 e = ++t; | |
3094 while (*e && (*e != *(t - 1))) e++; | |
3095 if (*e != '\0') { | |
3096 *e = '\0'; | |
3097 url = g_strdup (t); | |
3098 } | |
3099 } else { | |
3100 e = t; | |
3101 while (*e && !isspace ((gint) *e)) e++; | |
3102 if (*e == '\0') e--; | |
3103 *e = '\0'; | |
3104 url = g_strdup (t); | |
3105 } | |
3106 } | |
3107 } else if (!g_strcasecmp (tag, "</A>")) { | |
3108 if (url != NULL) { | |
1524
a5c87ada5143
[gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1519
diff
changeset
|
3109 got_tag = TRUE; |
1428 | 3110 NEW_BIT (NEW_TEXT_BIT); |
3111 g_free (url); | |
1524
a5c87ada5143
[gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1519
diff
changeset
|
3112 url = NULL; |
a5c87ada5143
[gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1519
diff
changeset
|
3113 } else { |
a5c87ada5143
[gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1519
diff
changeset
|
3114 intag = FALSE; |
a5c87ada5143
[gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1519
diff
changeset
|
3115 tpos = 0; |
a5c87ada5143
[gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1519
diff
changeset
|
3116 continue; |
1428 | 3117 } |
3118 } else if (!g_strncasecmp (tag, "<IMG ", strlen ("<IMG "))) { | |
3119 gchar *t, *e, *src = NULL; | |
3120 gchar *copy = g_strdup (tag); | |
3121 gchar **xpm; | |
3122 GdkColor *clr = NULL; | |
3123 GtkIMHtmlBit *bit; | |
3124 | |
3125 intag = FALSE; | |
3126 tpos = 0; | |
3127 | |
1453
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
3128 if (imhtml->img == NULL) { |
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
3129 ws [wpos] = 0; |
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
3130 strcat (ws, copy); |
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
3131 wpos = strlen (ws); |
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
3132 g_free (copy); |
1428 | 3133 continue; |
1453
ecf700f23852
[gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1449
diff
changeset
|
3134 } |
1428 | 3135 |
3136 t = tag + strlen ("<IMG"); | |
3137 do { | |
3138 gboolean quote = FALSE; | |
3139 if (*t == '\0') break; | |
3140 while (*t && !((*t == ' ') && !quote)) { | |
3141 if (*t == '\"') | |
3142 quote = ! quote; | |
3143 t++; | |
3144 } | |
3145 while (*t && (*t == ' ')) t++; | |
3146 } while (g_strncasecmp (t, "SRC=", strlen ("SRC="))); | |
3147 | |
3148 if (!g_strncasecmp (t, "SRC=", strlen ("SRC="))) { | |
3149 t += strlen ("SRC="); | |
3150 if ((*t == '\"') || (*t == '\'')) { | |
3151 e = ++t; | |
3152 while (*e && (*e != *(t - 1))) e++; | |
3153 if (*e != '\0') { | |
3154 *e = '\0'; | |
3155 src = g_strdup (t); | |
3156 } | |
3157 } else { | |
3158 e = t; | |
3159 while (*e && !isspace ((gint) *e)) e++; | |
3160 if (*e == '\0') e--; | |
3161 *e = '\0'; | |
3162 src = g_strdup (t); | |
3163 } | |
3164 } | |
3165 | |
3166 if (src == NULL) { | |
3167 ws [wpos] = 0; | |
3168 strcat (ws, copy); | |
3169 wpos = strlen (ws); | |
3170 g_free (copy); | |
3171 continue; | |
3172 } | |
3173 | |
3174 xpm = (* imhtml->img) (src); | |
3175 if (xpm == NULL) { | |
3176 g_free (src); | |
3177 ws [wpos] = 0; | |
3178 strcat (ws, copy); | |
3179 wpos = strlen (ws); | |
3180 g_free (copy); | |
3181 continue; | |
3182 } | |
3183 | |
3184 g_free (copy); | |
3185 | |
3186 if (!fonts || ((clr = ((FontDetail *)fonts->data)->back) == NULL)) | |
1460
36c56d591674
[gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
3187 clr = (bg != NULL) ? bg : imhtml->default_bg_color; |
1428 | 3188 |
3189 if (!GTK_WIDGET_REALIZED (imhtml)) | |
3190 gtk_widget_realize (GTK_WIDGET (imhtml)); | |
3191 | |
3192 bit = g_new0 (GtkIMHtmlBit, 1); | |
3193 bit->type = TYPE_IMG; | |
3194 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window, | |
3195 &bit->bm, | |
3196 clr, | |
3197 xpm); | |
3198 if (url) | |
3199 bit->url = g_strdup (url); | |
3200 | |
3201 NEW_BIT (bit); | |
3202 | |
3203 g_free (src); | |
3204 | |
3205 continue; | |
3206 } else if (!g_strcasecmp (tag, "<P>") || | |
3207 !g_strcasecmp (tag, "</P>") || | |
3208 !g_strncasecmp (tag, "<P ", strlen ("<P ")) || | |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
3209 !g_strcasecmp (tag, "<H3>") || |
1473
38e8391aa563
[gaim-migrate @ 1483]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1472
diff
changeset
|
3210 !g_strncasecmp (tag, "<H3 ", strlen ("<H3 ")) || |
1447
5df631739769
[gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1428
diff
changeset
|
3211 !g_strcasecmp (tag, "</H3>") || |
1428 | 3212 !g_strcasecmp (tag, "<HTML>") || |
3213 !g_strcasecmp (tag, "</HTML>") || | |
3214 !g_strcasecmp (tag, "<BODY>") || | |
3215 !g_strcasecmp (tag, "</BODY>") || | |
3216 !g_strcasecmp (tag, "<FONT>") || | |
3217 !g_strcasecmp (tag, "<HEAD>") || | |
3218 !g_strcasecmp (tag, "</HEAD>")) { | |
3219 intag = FALSE; | |
3220 tpos = 0; | |
3221 continue; | |
3222 } | |
3223 | |
3224 if (!got_tag) { | |
1463
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3225 char *d; |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3226 tag [tpos] = 0; |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3227 d = tag; |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3228 while (*d) { |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3229 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) { |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3230 ws [wpos] = 0; |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3231 wpos = 0; |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3232 NEW_BIT (NEW_TEXT_BIT); |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3233 g_snprintf (ws, smilelen + 1, "%s", d); |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3234 NEW_BIT (NEW_SMILEY_BIT); |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3235 d += smilelen; |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3236 } else if (*d == '&') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3237 gchar replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3238 gint length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3239 if (is_amp_escape (d, &replace, &length)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3240 ws [wpos++] = replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3241 d += length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3242 } else { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3243 ws [wpos++] = *d++; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3244 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3245 } else if (*d == '\n') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3246 if (!(options & GTK_IMHTML_NO_NEWLINE)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3247 ws [wpos] = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3248 wpos = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3249 NEW_BIT (NEW_TEXT_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3250 NEW_BIT (NEW_BR_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3251 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3252 d++; |
1463
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3253 } else { |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3254 ws [wpos++] = *d++; |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3255 } |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3256 } |
2f317467d2f9
[gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1462
diff
changeset
|
3257 tpos = 0; |
1428 | 3258 } else { |
3259 wpos = 0; | |
3260 } | |
3261 intag = FALSE; | |
3262 tpos = 0; | |
3263 } else if (*c == '&' && !intag) { | |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3264 gchar replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3265 gint length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3266 if (is_amp_escape (c, &replace, &length)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3267 ws [wpos++] = replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3268 c += length; |
1428 | 3269 } else { |
3270 ws [wpos++] = *c++; | |
3271 } | |
3272 } else if (intag) { | |
3273 if (*c == '\"') | |
1703
acce65ffdc80
[gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1691
diff
changeset
|
3274 tagquote++; |
1428 | 3275 tag [tpos++] = *c++; |
3276 } else if (incomment) { | |
3277 ws [wpos++] = *c++; | |
3278 } else if (((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0)) { | |
3279 ws [wpos] = 0; | |
3280 wpos = 0; | |
3281 NEW_BIT (NEW_TEXT_BIT); | |
3282 g_snprintf (ws, smilelen + 1, "%s", c); | |
3283 NEW_BIT (NEW_SMILEY_BIT); | |
3284 c += smilelen; | |
3285 } else if (*c == '\n') { | |
3286 if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
3287 ws [wpos] = 0; | |
3288 wpos = 0; | |
3289 NEW_BIT (NEW_TEXT_BIT); | |
3290 NEW_BIT (NEW_BR_BIT); | |
3291 } | |
3292 c++; | |
3293 } else { | |
3294 ws [wpos++] = *c++; | |
3295 } | |
3296 } | |
3297 | |
3298 if (intag) { | |
3299 tag [tpos] = 0; | |
3300 c = tag; | |
3301 while (*c) { | |
3302 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) { | |
3303 ws [wpos] = 0; | |
3304 wpos = 0; | |
3305 NEW_BIT (NEW_TEXT_BIT); | |
3306 g_snprintf (ws, smilelen + 1, "%s", c); | |
3307 NEW_BIT (NEW_SMILEY_BIT); | |
3308 c += smilelen; | |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3309 } else if (*c == '&') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3310 gchar replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3311 gint length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3312 if (is_amp_escape (c, &replace, &length)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3313 ws [wpos++] = replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3314 c += length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3315 } else { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3316 ws [wpos++] = *c++; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3317 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3318 } else if (*c == '\n') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3319 if (!(options & GTK_IMHTML_NO_NEWLINE)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3320 ws [wpos] = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3321 wpos = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3322 NEW_BIT (NEW_TEXT_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3323 NEW_BIT (NEW_BR_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3324 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3325 c++; |
1428 | 3326 } else { |
3327 ws [wpos++] = *c++; | |
3328 } | |
3329 } | |
3330 } else if (incomment) { | |
3331 ws [wpos] = 0; | |
3332 wpos = 0; | |
3333 strcat (tag, ws); | |
3334 ws [wpos] = 0; | |
3335 c = tag; | |
3336 while (*c) { | |
3337 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) { | |
3338 ws [wpos] = 0; | |
3339 wpos = 0; | |
3340 NEW_BIT (NEW_TEXT_BIT); | |
3341 g_snprintf (ws, smilelen + 1, "%s", c); | |
3342 NEW_BIT (NEW_SMILEY_BIT); | |
3343 c += smilelen; | |
1472
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3344 } else if (*c == '&') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3345 gchar replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3346 gint length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3347 if (is_amp_escape (c, &replace, &length)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3348 ws [wpos++] = replace; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3349 c += length; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3350 } else { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3351 ws [wpos++] = *c++; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3352 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3353 } else if (*c == '\n') { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3354 if (!(options & GTK_IMHTML_NO_NEWLINE)) { |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3355 ws [wpos] = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3356 wpos = 0; |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3357 NEW_BIT (NEW_TEXT_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3358 NEW_BIT (NEW_BR_BIT); |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3359 } |
be620a051d6d
[gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1463
diff
changeset
|
3360 c++; |
1428 | 3361 } else { |
3362 ws [wpos++] = *c++; | |
3363 } | |
3364 } | |
3365 } | |
3366 | |
3367 ws [wpos] = 0; | |
3368 NEW_BIT (NEW_TEXT_BIT); | |
3369 | |
3370 while (newbits) { | |
3371 GtkIMHtmlBit *bit = newbits->data; | |
3372 imhtml->bits = g_list_append (imhtml->bits, bit); | |
3373 newbits = g_list_remove (newbits, bit); | |
3374 gtk_imhtml_draw_bit (imhtml, bit); | |
3375 } | |
3376 | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3377 GTK_LAYOUT (imhtml)->height = imhtml->y; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3378 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3379 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
|
3380 |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3381 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y); |
1428 | 3382 |
3383 if (!(options & GTK_IMHTML_NO_SCROLL) && | |
3384 scrolldown && | |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3385 (imhtml->y >= MAX (1, |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3386 (GTK_WIDGET (imhtml)->allocation.height - |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3387 (GTK_WIDGET (imhtml)->style->klass->ythickness + BORDER_SIZE) * 2)))) |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3388 gtk_adjustment_set_value (vadj, imhtml->y - |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3389 MAX (1, (GTK_WIDGET (imhtml)->allocation.height - |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3390 (GTK_WIDGET (imhtml)->style->klass->ythickness + |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3391 BORDER_SIZE) * 2))); |
1428 | 3392 |
3393 if (url) { | |
3394 g_free (url); | |
3395 if (retval) | |
3396 retval = g_string_append (retval, "</A>"); | |
3397 } | |
3398 if (bg) | |
3399 gdk_color_free (bg); | |
3400 while (fonts) { | |
3401 FontDetail *font = fonts->data; | |
3402 fonts = g_slist_remove (fonts, font); | |
3403 g_free (font->face); | |
3404 if (font->fore) | |
3405 gdk_color_free (font->fore); | |
3406 if (font->back) | |
3407 gdk_color_free (font->back); | |
3408 g_free (font); | |
3409 if (retval) | |
3410 retval = g_string_append (retval, "</FONT>"); | |
3411 } | |
3412 if (retval) { | |
3413 while (bold) { | |
3414 retval = g_string_append (retval, "</B>"); | |
3415 bold--; | |
3416 } | |
3417 while (italics) { | |
3418 retval = g_string_append (retval, "</I>"); | |
3419 italics--; | |
3420 } | |
3421 while (underline) { | |
3422 retval = g_string_append (retval, "</U>"); | |
3423 underline--; | |
3424 } | |
3425 while (strike) { | |
3426 retval = g_string_append (retval, "</S>"); | |
3427 strike--; | |
3428 } | |
3429 while (sub) { | |
3430 retval = g_string_append (retval, "</SUB>"); | |
3431 sub--; | |
3432 } | |
3433 while (sup) { | |
3434 retval = g_string_append (retval, "</SUP>"); | |
3435 sup--; | |
3436 } | |
3437 while (title) { | |
3438 retval = g_string_append (retval, "</TITLE>"); | |
3439 title--; | |
3440 } | |
1691
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
3441 while (pre) { |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
3442 retval = g_string_append (retval, "</PRE>"); |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
3443 pre--; |
d802b115800f
[gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1647
diff
changeset
|
3444 } |
1428 | 3445 } |
3446 g_free (ws); | |
3447 g_free (tag); | |
3448 | |
3449 return retval; | |
3450 } | |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3451 |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3452 void |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3453 gtk_imhtml_clear (GtkIMHtml *imhtml) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3454 { |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3455 GtkLayout *layout; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3456 |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3457 g_return_if_fail (imhtml != NULL); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3458 g_return_if_fail (GTK_IS_IMHTML (imhtml)); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3459 |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3460 layout = GTK_LAYOUT (imhtml); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3461 |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3462 while (imhtml->bits) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3463 GtkIMHtmlBit *bit = imhtml->bits->data; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3464 imhtml->bits = g_list_remove (imhtml->bits, bit); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3465 if (bit->text) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3466 g_free (bit->text); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3467 if (bit->font) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3468 gdk_font_unref (bit->font); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3469 if (bit->fore) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3470 gdk_color_free (bit->fore); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3471 if (bit->back) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3472 gdk_color_free (bit->back); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3473 if (bit->bg) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3474 gdk_color_free (bit->bg); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3475 if (bit->url) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3476 g_free (bit->url); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3477 if (bit->pm) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3478 gdk_pixmap_unref (bit->pm); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3479 if (bit->bm) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3480 gdk_bitmap_unref (bit->bm); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3481 while (bit->chunks) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3482 struct line_info *li = bit->chunks->data; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3483 if (li->text) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3484 g_free (li->text); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3485 bit->chunks = g_list_remove (bit->chunks, li); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3486 g_free (li); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3487 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3488 g_free (bit); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3489 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3490 |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3491 while (imhtml->urls) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3492 g_free (imhtml->urls->data); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3493 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3494 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3495 |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3496 if (imhtml->selected_text) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3497 g_string_free (imhtml->selected_text, TRUE); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3498 imhtml->selected_text = g_string_new (""); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3499 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3500 |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3501 imhtml->sel_startx = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3502 imhtml->sel_starty = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3503 imhtml->sel_endx = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3504 imhtml->sel_endx = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3505 imhtml->sel_endchunk = NULL; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3506 |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3507 if (imhtml->tip_timer) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3508 gtk_timeout_remove (imhtml->tip_timer); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3509 imhtml->tip_timer = 0; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3510 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3511 if (imhtml->tip_window) { |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3512 gtk_widget_destroy (imhtml->tip_window); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3513 imhtml->tip_window = NULL; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3514 } |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3515 imhtml->tip_bit = NULL; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3516 |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3517 if (imhtml->scroll_timer) { |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3518 gtk_timeout_remove (imhtml->scroll_timer); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3519 imhtml->scroll_timer = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3520 } |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3521 |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3522 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
|
3523 |
1998
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3524 imhtml->x = 0; |
00dc6b2df5b6
[gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1997
diff
changeset
|
3525 imhtml->y = TOP_BORDER; |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3526 imhtml->xsize = 0; |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3527 imhtml->llheight = 0; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3528 imhtml->llascent = 0; |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3529 if (imhtml->line) |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3530 g_list_free (imhtml->line); |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3531 imhtml->line = NULL; |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3532 |
2621
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3533 layout->hadjustment->page_size = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3534 layout->hadjustment->page_increment = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3535 layout->hadjustment->lower = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3536 layout->hadjustment->upper = imhtml->x; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3537 gtk_adjustment_set_value (layout->hadjustment, 0); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3538 |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3539 layout->vadjustment->page_size = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3540 layout->vadjustment->page_increment = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3541 layout->vadjustment->lower = 0; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3542 layout->vadjustment->upper = imhtml->y; |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3543 gtk_adjustment_set_value (layout->vadjustment, 0); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3544 |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3545 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed"); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3546 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed"); |
f8b02cf4af94
[gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2615
diff
changeset
|
3547 |
1780
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3548 if (GTK_WIDGET_REALIZED (GTK_WIDGET (imhtml))) |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3549 gdk_window_clear (GTK_LAYOUT (imhtml)->bin_window); |
d7cbedd1d651
[gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1738
diff
changeset
|
3550 } |
2363
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3551 |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3552 void |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3553 gtk_imhtml_page_up (GtkIMHtml *imhtml) |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3554 { |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3555 GtkAdjustment *vadj; |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3556 |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3557 g_return_if_fail (imhtml != NULL); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3558 g_return_if_fail (GTK_IS_IMHTML (imhtml)); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3559 |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3560 vadj = GTK_LAYOUT (imhtml)->vadjustment; |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3561 gtk_adjustment_set_value (vadj, MAX (vadj->value - vadj->page_increment, |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3562 vadj->lower)); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3563 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed"); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3564 } |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3565 |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3566 void |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3567 gtk_imhtml_page_down (GtkIMHtml *imhtml) |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3568 { |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3569 GtkAdjustment *vadj; |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3570 |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3571 g_return_if_fail (imhtml != NULL); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3572 g_return_if_fail (GTK_IS_IMHTML (imhtml)); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3573 |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3574 vadj = GTK_LAYOUT (imhtml)->vadjustment; |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3575 gtk_adjustment_set_value (vadj, MIN (vadj->value + vadj->page_increment, |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3576 vadj->upper - vadj->page_size)); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3577 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed"); |
08c66712364c
[gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2349
diff
changeset
|
3578 } |