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