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