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