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