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