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