annotate src/gtkimhtml.c @ 2694:91f4da998025

[gaim-migrate @ 2707] people are going to hate me for this but for some reason my encoding was coming up as ANSI_X3.4-1968. so it didn't work for me, so i removed it. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 08 Nov 2001 02:39:02 +0000
parents 2c746e70f2b3
children d4be9f5b8d58
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * GtkIMHtml
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 2000, Eric Warmenhoven <warmenhoven@yahoo.com>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * under the terms of the GNU General Public License as published by
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <gtk/gtk.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <stdio.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #include "pixmaps/angel.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include "pixmaps/bigsmile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include "pixmaps/burp.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #include "pixmaps/crossedlips.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #include "pixmaps/cry.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #include "pixmaps/embarrassed.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #include "pixmaps/kiss.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #include "pixmaps/moneymouth.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #include "pixmaps/sad.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #include "pixmaps/scream.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #include "pixmaps/smile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #include "pixmaps/smile8.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #include "pixmaps/think.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 #include "pixmaps/tongue.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #include "pixmaps/wink.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 #include "pixmaps/yell.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #define MAX_SIZE 7
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 gint font_sizes [] = { 80, 100, 120, 140, 200, 300, 400 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
66 #define BORDER_SIZE 2
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
67 #define TOP_BORDER 10
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 #define MIN_HEIGHT 20
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 #define HR_HEIGHT 2
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
70 #define TOOLTIP_TIMEOUT 500
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
72 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
73 #define COLOR_MOD 0x8000
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
74 #define COLOR_DIFF 0x800
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
75
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 #define TYPE_TEXT 0
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 #define TYPE_SMILEY 1
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 #define TYPE_IMG 2
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 #define TYPE_SEP 3
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 #define TYPE_BR 4
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 #define TYPE_COMMENT 5
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
83 #define DRAW_IMG(x) (((x)->type == TYPE_IMG) || (imhtml->smileys && ((x)->type == TYPE_SMILEY)))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
84
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 typedef struct _GtkIMHtmlBit GtkIMHtmlBit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 typedef struct _FontDetail FontDetail;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
88 struct _GtkSmileyTree {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
89 GString *values;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
90 GtkSmileyTree **children;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
91 gchar **image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
92 };
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
93
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
94 static GtkSmileyTree*
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
95 gtk_smiley_tree_new ()
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
96 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
97 return g_new0 (GtkSmileyTree, 1);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
98 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
99
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
100 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
101 gtk_smiley_tree_insert (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
102 const gchar *text,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
103 gchar **image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
104 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
105 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
106 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
107
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
108 if (!strlen (x))
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
109 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
110
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
111 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
112 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
113 gint index;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
114
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
115 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
116 t->values = g_string_new ("");
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
117
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
118 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
119 if (!pos) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
120 t->values = g_string_append_c (t->values, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
121 index = t->values->len - 1;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
122 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
123 t->children [index] = g_new0 (GtkSmileyTree, 1);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
124 } else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
125 index = (int) pos - (int) t->values->str;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
126
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
127 t = t->children [index];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
128
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
129 x++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
130 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
131
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
132 t->image = image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
133 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
134
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
135 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
136 gtk_smiley_tree_remove (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
137 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
138 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
139 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
140 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
141 gint len = 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
142
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
143 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
144 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
145
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
146 if (t->image) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
147 t->image = NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
148 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
149 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
150
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
151 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
152 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
153
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
154 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
155 if (pos)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
156 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
157 else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
158 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
159
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
160 x++; len++;
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
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
163 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
164 t->image = NULL;
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
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
167 static gint
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
168 gtk_smiley_tree_lookup (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
169 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
170 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
171 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
172 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
173 gint len = 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
174
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
175 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
176 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
177
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
178 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
179 return len;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
180
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
181 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
182 return 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
183
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
184 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
185 if (pos)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
186 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
187 else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
188 return 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
189
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
190 x++; len++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
191 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
192
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
193 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
194 return len;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
195
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
196 return 0;
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
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
199 static gchar**
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
200 gtk_smiley_tree_image (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
201 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
202 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
203 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
204 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
205
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
206 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
207 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
208
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
209 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
210 return NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
211
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
212 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
213 if (pos) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
214 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
215 } else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
216 return NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
217
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
218 x++;
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
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
221 return t->image;
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
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
224 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
225 gtk_smiley_tree_destroy (GtkSmileyTree *tree)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
226 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
227 GSList *list = g_slist_append (NULL, tree);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
228
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
229 while (list) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
230 GtkSmileyTree *t = list->data;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
231 gint i;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
232 list = g_slist_remove(list, t);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
233 if (t->values) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
234 for (i = 0; i < t->values->len; i++)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
235 list = g_slist_append (list, t->children [i]);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
236 g_string_free (t->values, TRUE);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
237 g_free (t->children);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
238 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
239 g_free (t);
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 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
242
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 struct _GtkIMHtmlBit {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 gint type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 GdkPixmap *pm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 GdkBitmap *bm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 GdkColor *bg;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 gboolean underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 gboolean strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 gchar *url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 struct _FontDetail {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 gushort size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 gchar *face;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 struct line_info {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 gint height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 gint ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 gboolean selected;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 gchar *sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 gchar *sel_end;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 struct url_widget {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 gint height;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
288 GtkIMHtml *imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
289 GtkIMHtmlBit *bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 static GtkLayoutClass *parent_class = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 TARGET_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 TARGET_TEXT,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 TARGET_COMPOUND_TEXT
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 LAST_SIGNAL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 static void gtk_imhtml_draw_bit (GtkIMHtml *, GtkIMHtmlBit *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 static GdkColor *gtk_imhtml_get_color (const gchar *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 static gint gtk_imhtml_motion_notify_event (GtkWidget *, GdkEventMotion *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 static void
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
311 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
312 gtk_imhtml_finalize (GObject *object)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
313 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 gtk_imhtml_destroy (GtkObject *object)
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
315 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 imhtml = GTK_IMHTML (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 while (imhtml->bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 GtkIMHtmlBit *bit = imhtml->bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 imhtml->bits = g_list_remove (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 if (bit->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 g_free (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 if (bit->font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 gdk_font_unref (bit->font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 if (bit->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 gdk_color_free (bit->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 if (bit->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 gdk_color_free (bit->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 if (bit->bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 gdk_color_free (bit->bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 if (bit->url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 g_free (bit->url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 if (bit->pm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 gdk_pixmap_unref (bit->pm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 if (bit->bm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 gdk_bitmap_unref (bit->bm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 while (bit->chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
341 struct line_info *li = bit->chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 if (li->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 g_free (li->text);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
344 bit->chunks = g_list_remove (bit->chunks, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 g_free (li);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 g_free (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
350 if (imhtml->line)
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
351 g_list_free (imhtml->line);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
352
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 if (imhtml->selected_text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
361 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
362 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
363 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
364 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
365 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
366 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
367 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
368 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
369 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
370
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
371 if (imhtml->default_font)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
372 gdk_font_unref (imhtml->default_font);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
373 if (imhtml->default_fg_color)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
374 gdk_color_free (imhtml->default_fg_color);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
375 if (imhtml->default_bg_color)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
376 gdk_color_free (imhtml->default_bg_color);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 gdk_cursor_destroy (imhtml->hand_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 gdk_cursor_destroy (imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
381 gtk_smiley_tree_destroy (imhtml->smiley_data);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
383 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
384 G_OBJECT_CLASS (parent_class)->finalize (object);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
385 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
388 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 gtk_imhtml_realize (GtkWidget *widget)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 GtkIMHtml *imhtml;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
395 GdkWindowAttr attributes;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
396 gint attributes_mask;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 imhtml = GTK_IMHTML (widget);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
402 GTK_WIDGET_SET_FLAGS (imhtml, GTK_REALIZED);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
403
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
404 attributes.window_type = GDK_WINDOW_CHILD;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
405 attributes.x = widget->allocation.x;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
406 attributes.y = widget->allocation.y;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
407 attributes.width = widget->allocation.width;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
408 attributes.height = widget->allocation.height;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
409 attributes.wclass = GDK_INPUT_OUTPUT;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
410 attributes.visual = gtk_widget_get_visual (widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
411 attributes.colormap = gtk_widget_get_colormap (widget);
2556
e284ab2882bd [gaim-migrate @ 2569]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
412 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
413
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
414 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
415
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
416 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
417 &attributes, attributes_mask);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
418 gdk_window_set_user_data (widget->window, widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
419
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
420 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
421 attributes.x = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
422 attributes.y = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
423 #else
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
424 attributes.x = widget->style->klass->xthickness + BORDER_SIZE;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
425 attributes.y = widget->style->klass->xthickness + BORDER_SIZE;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
426 #endif
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
427 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
428 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
429 attributes.event_mask = gtk_widget_get_events (widget)
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
430 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
431 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
432
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
433 GTK_LAYOUT (imhtml)->bin_window = gdk_window_new (widget->window,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
434 &attributes, attributes_mask);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
435 gdk_window_set_user_data (GTK_LAYOUT (imhtml)->bin_window, widget);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 widget->style = gtk_style_attach (widget->style, widget->window);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
441 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
442
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
443 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
444 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
445 &widget->style->base [GTK_STATE_NORMAL]);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
446
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
447 imhtml->default_fg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
448 imhtml->default_bg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
449
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
450 gdk_window_show (GTK_LAYOUT (imhtml)->bin_window);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
451 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
452
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
453 static gboolean
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
454 similar_colors (GdkColor *bg,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
455 GdkColor *fg)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
456 {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
457 if ((DIFF (bg->red, fg->red) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
458 (DIFF (bg->green, fg->green) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
459 (DIFF (bg->blue, fg->blue) < COLOR_DIFF)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
460 fg->red = (0xff00 - COLOR_MOD > bg->red) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
461 bg->red + COLOR_MOD : bg->red - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
462 fg->green = (0xff00 - COLOR_MOD > bg->green) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
463 bg->green + COLOR_MOD : bg->green - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
464 fg->blue = (0xff00 - COLOR_MOD > bg->blue) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
465 bg->blue + COLOR_MOD : bg->blue - COLOR_MOD;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
466 return TRUE;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
467 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
468 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
472 draw_text (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
473 struct line_info *line)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
475 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
476 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
477 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
478 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
479 gfloat xoff, yoff;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
480 GdkColor *bg, *fg;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
481
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
482 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
483 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
484
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
485 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
486 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
487 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
488 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
489 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
490
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
491 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
492 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
493 gdk_gc_set_foreground (gc, bit->bg);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
494 bg = bit->bg;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
495 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
496 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
497 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
498 bg = imhtml->default_bg_color;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
499 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
500
2338
2bf8a8131479 [gaim-migrate @ 2351]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2337
diff changeset
501 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
502 line->width ? line->width : imhtml->xsize, line->height);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
503
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
504 if (!line->text) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
505 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
506 return;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
507 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
508
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
509 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
510 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
511 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
512 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
513 gdk_string_width (bit->font, line->text), line->height);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
514 bg = bit->back;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
515 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
516
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
517 bg = gdk_color_copy (bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
518
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
519 if (line->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
520 gint width, x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
521 gchar *start, *end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
522 GdkColor col;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
523
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
524 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
525 start = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
526 end = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
527 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
528 start = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
529 end = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
530 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
531
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
532 if (start == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
533 x = 0;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
534 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
535 x = gdk_text_width (bit->font, line->text, start - line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
536
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
537 if (end == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
538 width = gdk_string_width (bit->font, line->text) - x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
539 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
540 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
541
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
542 col.red = col.green = col.blue = 0xc000;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
543 gdk_color_alloc (cmap, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
544 gdk_gc_set_foreground (gc, &col);
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 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
547 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
548 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
549
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
550 if (bit->url) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
551 GdkColor *tc = gtk_imhtml_get_color ("#0000a0");
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
552 gdk_color_alloc (cmap, tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
553 gdk_gc_set_foreground (gc, tc);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
554 fg = gdk_color_copy (tc);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
555 gdk_color_free (tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
556 } else if (bit->fore) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
557 gdk_color_alloc (cmap, bit->fore);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
558 gdk_gc_set_foreground (gc, bit->fore);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
559 fg = gdk_color_copy (bit->fore);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
560 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
561 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
562 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
563 fg = gdk_color_copy (imhtml->default_fg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
564 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
565
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
566 if (similar_colors (bg, fg)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
567 gdk_color_alloc (cmap, fg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
568 gdk_gc_set_foreground (gc, fg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
569 }
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
570 gdk_color_free (bg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
571 gdk_color_free (fg);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
572
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
573 gdk_draw_string (window, bit->font, gc, line->x - xoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
574 line->y - yoff + line->ascent, line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
575
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
576 if (bit->underline || bit->url)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
577 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
578 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
579 if (bit->strike)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
580 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
581 line->y - yoff + line->ascent - (bit->font->ascent / 2),
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
582 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
583
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
584 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
585 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
586
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
587 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
588 draw_img (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
589 struct line_info *line)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
590 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
591 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
592 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
593 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
594 gint width, height, hoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
595 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
596 gfloat xoff, yoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
597
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
598 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
599 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
600
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
601 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
602 gdk_window_get_size (bit->pm, &width, &height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
603 hoff = (line->height - height) / 2;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
604 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
605 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
606 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
607 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
608
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
609 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
610 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
611 gdk_gc_set_foreground (gc, bit->bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
612 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
613 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
614 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
615 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
616
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
617 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
618
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
619 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
620 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
621 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
622 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
623 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
624 }
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_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
627
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
628 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
629 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
630
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
631 static void
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
632 draw_line (GtkIMHtml *imhtml,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
633 struct line_info *line)
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
634 {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
635 GtkIMHtmlBit *bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
636 GdkDrawable *drawable;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
637 GdkColormap *cmap;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
638 GdkGC *gc;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
639 guint line_height;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
640 gfloat xoff, yoff;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
641
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
642 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
643 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
644
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
645 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
646 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
647 bit = line->bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
648 drawable = GTK_LAYOUT (imhtml)->bin_window;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
649 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
650 gc = gdk_gc_new (drawable);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
651
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
652 if (bit->bg != NULL) {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
653 gdk_color_alloc (cmap, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
654 gdk_gc_set_foreground (gc, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
655
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
656 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
657 line->width, line->height);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
658 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
659
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
660 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
661 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
662
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
663 line_height = line->height / 2;
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 + line_height / 2,
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 gdk_gc_unref (gc);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
669 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
670
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
671 static void
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
672 gtk_imhtml_draw_focus (GtkWidget *widget)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
673 {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
674 GtkIMHtml *imhtml;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
675 gint x = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
676 y = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
677 w = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
678 h = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
679
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
680 imhtml = GTK_IMHTML (widget);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
681
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
682 if (!GTK_WIDGET_DRAWABLE (widget))
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
683 return;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
684
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
685 if (GTK_WIDGET_HAS_FOCUS (widget)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
686 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
687 widget->allocation.width - 1, widget->allocation.height - 1);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
688 x = 1; y = 1; w = 2; h = 2;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
689 }
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
690
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
691 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
692 GTK_SHADOW_IN, NULL, widget, "text", x, y,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
693 widget->allocation.width - w, widget->allocation.height - h);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
694 }
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
695
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
696 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
697 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
698 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
699 GList *bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
700 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
701 GList *chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
702 struct line_info *line;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
703 gfloat x, y;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
704 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
705 guint32 width, height;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
706 #else
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2022
diff changeset
707 gint width, height;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
708 #endif
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
709
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
710 x = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
711 y = GTK_LAYOUT (imhtml)->vadjustment->value;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
712 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
713
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
714 bits = imhtml->bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
715
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
716 while (bits) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
717 bit = bits->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
718 chunks = bit->chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
719 if (DRAW_IMG (bit)) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
720 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
721 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
722 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
723 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
724 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
725 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
726 draw_img (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
727 }
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
728 } else if (bit->type == TYPE_SEP) {
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_line (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
736
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
737 line = chunks->next->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
738 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
739 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
740 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
741 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
742 draw_text (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
743 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
744 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
745 while (chunks) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
746 line = chunks->data;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
747 if ((line->x <= x + width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
748 (line->y <= y + height) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
749 (x <= line->x + line->width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
750 (y <= line->y + line->height))
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
751 draw_text (imhtml, line);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
752 chunks = g_list_next (chunks);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
753 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
754 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
755 bits = g_list_next (bits);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
756 }
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
757
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
758 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
761 #if !GTK_CHECK_VERSION(1,3,0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 gtk_imhtml_draw (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 GdkRectangle *area)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
766 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
767
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
768 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
769 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 }
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
771 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 gtk_imhtml_style_set (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775 GtkStyle *style)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 g_return_if_fail (GTK_IS_IMHTML (widget));
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
781
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
782 if (GTK_WIDGET_CLASS (parent_class)->style_set)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
783 (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, style);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
784
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 if (!GTK_WIDGET_REALIZED (widget))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 imhtml = GTK_IMHTML (widget);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
789 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 static gint
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
793 gtk_imhtml_expose_event (GtkWidget *widget,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
794 GdkEventExpose *event)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
796 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
797
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
798 g_return_val_if_fail (widget != NULL, FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
799 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
800
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
801 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
802 gtk_imhtml_draw_exposed (imhtml);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
803
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
804 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 gtk_imhtml_redraw_all (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810 GList *b;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 gfloat oldvalue;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
814 gint oldy;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
816 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 oldvalue = vadj->value / vadj->upper;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
818 oldy = imhtml->y;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
820 gtk_layout_freeze (GTK_LAYOUT (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
830 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
831 imhtml->y = TOP_BORDER;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834
2002
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
835 if (GTK_LAYOUT (imhtml)->yoffset < TOP_BORDER)
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
836 gdk_window_clear_area (GTK_LAYOUT (imhtml)->bin_window, 0, 0,
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
837 imhtml->xsize, TOP_BORDER - GTK_LAYOUT (imhtml)->yoffset);
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
838
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 b = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 while (b) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
841 bit = b->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 b = g_list_next (b);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
843 while (bit->chunks) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
844 struct line_info *li = bit->chunks->data;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
845 if (li->text)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
846 g_free (li->text);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
847 bit->chunks = g_list_remove (bit->chunks, li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
848 g_free (li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
849 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
850 gtk_imhtml_draw_bit (imhtml, bit);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
853 GTK_LAYOUT (imhtml)->height = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
854 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
855 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
856
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
857 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 gtk_adjustment_set_value (vadj, vadj->upper * oldvalue);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
859
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
860 if (GTK_LAYOUT (imhtml)->bin_window && (imhtml->y < oldy)) {
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
861 GdkGC *gc;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
862 GdkColormap *cmap;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
863
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
864 gc = gdk_gc_new (GTK_LAYOUT (imhtml)->bin_window);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
865 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
866
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
867 gdk_color_alloc (cmap, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
868 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
869
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
870 gdk_draw_rectangle (GTK_LAYOUT (imhtml)->bin_window, gc, TRUE,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
871 0, imhtml->y - GTK_LAYOUT (imhtml)->vadjustment->value,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
872 GTK_WIDGET (imhtml)->allocation.width,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
873 oldy - imhtml->y);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
874
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
875 gdk_gc_unref (gc);
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
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
878 gtk_layout_thaw (GTK_LAYOUT (imhtml));
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
879 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
880 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 gtk_imhtml_size_allocate (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 GtkAllocation *allocation)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 GtkIMHtml *imhtml;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
887 GtkLayout *layout;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
888 gint new_xsize, new_ysize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 g_return_if_fail (allocation != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 imhtml = GTK_IMHTML (widget);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
895 layout = GTK_LAYOUT (widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
896
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
897 widget->allocation = *allocation;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
898
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
899 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
900 new_xsize = MAX (1, (gint) allocation->width -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
901 (gint) (widget->style->xthickness + BORDER_SIZE) * 2);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
902 new_ysize = MAX (1, (gint) allocation->height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
903 (gint) (widget->style->ythickness + BORDER_SIZE) * 2);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
904
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
905 if (GTK_WIDGET_REALIZED (widget)) {
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
906 gint x = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
907 gint y = widget->style->ythickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
908 gdk_window_move_resize (widget->window,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
909 allocation->x, allocation->y,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
910 allocation->width, allocation->height);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
911 gdk_window_move_resize (layout->bin_window,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
912 x, y, new_xsize, new_ysize);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
913 }
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
914 #else
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
915 new_xsize = MAX (1, (gint) allocation->width -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
916 (gint) (widget->style->klass->xthickness + BORDER_SIZE) * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
917 new_ysize = MAX (1, (gint) allocation->height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
918 (gint) (widget->style->klass->ythickness + BORDER_SIZE) * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
919
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
920 if (GTK_WIDGET_REALIZED (widget)) {
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
921 gint x = widget->style->klass->xthickness + BORDER_SIZE;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
922 gint y = widget->style->klass->ythickness + BORDER_SIZE;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
923 gdk_window_move_resize (widget->window,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
924 allocation->x, allocation->y,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
925 allocation->width, allocation->height);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
926 gdk_window_move_resize (layout->bin_window,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
927 x, y, new_xsize, new_ysize);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
928 }
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
929 #endif
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
930
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
931 layout->hadjustment->page_size = new_xsize;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
932 layout->hadjustment->page_increment = new_xsize / 2;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
933 layout->hadjustment->lower = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
934 layout->hadjustment->upper = imhtml->x;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
935
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
936 layout->vadjustment->page_size = new_ysize;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
937 layout->vadjustment->page_increment = new_ysize / 2;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
938 layout->vadjustment->lower = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
939 layout->vadjustment->upper = imhtml->y;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
940
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
941 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
942 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
944 if (new_xsize == imhtml->xsize) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
945 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y - new_ysize)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
946 if (imhtml->y > new_ysize)
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
947 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
948 imhtml->y - new_ysize);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
949 else
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
950 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, 0);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
951 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 return;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
953 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
955 imhtml->xsize = new_xsize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
957 if (GTK_WIDGET_REALIZED (widget))
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
958 gtk_imhtml_redraw_all (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 gtk_imhtml_select_none (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
977 chunk = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
978
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
979 if (chunk->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
980 chunk->selected = FALSE;
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
981 chunk->sel_start = chunk->text;
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
982 chunk->sel_end = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
983 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
984 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
985 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
986 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
987 else if (chunk->width)
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
988 draw_text (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
989 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 }
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
996 imhtml->sel_endchunk = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999 static gchar*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 get_position (struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001 gint x,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 gint width = x - chunk->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 gchar *pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 guint total = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 if (smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 if (width <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026 return text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1027
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028 for (pos = text; *pos != '\0'; pos++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 gint char_width = gdk_text_width (chunk->bit->font, pos, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 if ((width > total) && (width <= total + char_width)) {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1031 if (width < total + (char_width / 2))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 return ++pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036 total += char_width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042 static GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043 append_to_sel (GString *string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044 struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1046 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1047 GString *new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048 gchar *buf;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 gchar *start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 if (smileys) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 start = (chunk->sel_start == NULL) ? chunk->bit->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1073 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1074 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1076 case TYPE_BR:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1077 buf = g_strdup ("\n");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 new_string = g_string_append (string, buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 g_free (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1087 return new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 #define COORDS_IN_CHUNK(xx, yy) (((xx) < chunk->x + chunk->width) && \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 ((yy) < chunk->y + chunk->height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 gtk_imhtml_select_bits (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1100
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1101 guint startx = imhtml->sel_startx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102 starty = imhtml->sel_starty,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 endx = imhtml->sel_endx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104 endy = imhtml->sel_endy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 gchar *new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106 gint selection = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 gboolean smileys = imhtml->smileys;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 gboolean redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 gboolean got_start = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 gboolean got_end = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1113
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 if (!imhtml->selection)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117 if (imhtml->selected_text) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1125 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1128 chunk = chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 switch (selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 case 0:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 if (COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1133 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1138 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1140 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1142 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1143 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 if (COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146 if (got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148 if (chunk->sel_end != new_pos)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 if (chunk->sel_start > new_pos) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 chunk->sel_end = chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 selection = 2;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1156 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1168 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 } else if (!COORDS_IN_CHUNK (startx, starty) && !got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172 if (chunk->selected)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 if (!got_start && COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 } else if (!got_end && COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1202 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 if ( !chunk->selected ||
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1206 (chunk->sel_end != NULL) ||
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1207 (chunk->sel_start != chunk->text))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 case 2:
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1216 if (chunk->selected)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224 if (chunk->selected == TRUE)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225 imhtml->selected_text = append_to_sel (imhtml->selected_text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 chunk, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 if (redraw) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1229 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1230 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1231 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1232 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1233 else if (chunk->width)
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1234 draw_text (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235 redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1245 static void
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1246 gtk_imhtml_select_in_chunk (GtkIMHtml *imhtml,
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1247 struct line_info *chunk)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1248 {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1249 GtkIMHtmlBit *bit = chunk->bit;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1250 gchar *new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1251 guint endx = imhtml->sel_endx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1252 guint startx = imhtml->sel_startx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1253 guint starty = imhtml->sel_starty;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1254 gboolean smileys = imhtml->smileys;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1255 gboolean redraw = FALSE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1256
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1257 new_pos = get_position (chunk, endx, smileys);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1258 if ((starty < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1259 ((starty < chunk->y + chunk->height) && (startx < endx))) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1260 if (chunk->sel_end != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1261 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1262 chunk->sel_end = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1263 } else {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1264 if (chunk->sel_start != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1265 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1266 chunk->sel_start = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1267 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1268
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1269 if (redraw) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1270 if (DRAW_IMG (bit))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1271 draw_img (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1272 else if ((bit->type == TYPE_SEP) &&
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1273 (bit->chunks->data == chunk))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1274 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1275 else if (chunk->width)
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1276 draw_text (imhtml, chunk);
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
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281 scroll_timeout (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 GdkEventMotion event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1285 GdkModifierType mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1289 gdk_window_get_pointer (GTK_LAYOUT (imhtml)->bin_window, &x, &y, &mask);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291 if (mask & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 event.is_hint = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293 event.x = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 event.y = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 event.state = mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 gtk_imhtml_motion_notify_event (GTK_WIDGET (imhtml), &event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303 static gint
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1304 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1305 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1306 GtkStyle *style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1307 GdkFont *font;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1308 gint y, baseline_skip, gap;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1309
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1310 style = imhtml->tip_window->style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1311 font = GTK_IMHTML_GET_STYLE_FONT (style);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1312
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1313 gap = (font->ascent + font->descent) / 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1314 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1315 gap = 2;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1316 baseline_skip = font->ascent + font->descent + gap;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1317
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1318 if (!imhtml->tip_bit)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1319 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1320
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1321 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
1322 NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1323
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1324 y = font->ascent + 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1325 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
1326 imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->url);
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 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1329 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1330
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1331 static gint
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1332 gtk_imhtml_tip (gpointer data)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1333 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1334 GtkIMHtml *imhtml = data;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1335 GtkWidget *widget = GTK_WIDGET (imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1336 GtkStyle *style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1337 GdkFont *font;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1338 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
1339
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1340 if (!imhtml->tip_bit || !GTK_WIDGET_DRAWABLE (widget)) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1341 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1342 return FALSE;
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
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1345 if (imhtml->tip_window)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1346 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1347
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1348 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1349 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1350 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
1351 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips");
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1352 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "expose_event",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1353 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1354 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "draw",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1355 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1356
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1357 gtk_widget_ensure_style (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1358 style = imhtml->tip_window->style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1359 font = GTK_IMHTML_GET_STYLE_FONT (style);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1360
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1361 scr_w = gdk_screen_width ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1362 scr_h = gdk_screen_height ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1363
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1364 gap = (font->ascent + font->descent) / 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1365 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1366 gap = 2;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1367 baseline_skip = font->ascent + font->descent + gap;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1368
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1369 w = 8 + gdk_string_width (font, imhtml->tip_bit->url);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1370 h = 8 - gap + baseline_skip;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1371
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1372 gdk_window_get_pointer (NULL, &x, &y, NULL);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1373 if (GTK_WIDGET_NO_WINDOW (widget))
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1374 y += widget->allocation.y;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1375
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1376 x -= ((w >> 1) + 4);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1377
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1378 if ((x + w) > scr_w)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1379 x -= (x + w) - scr_w;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1380 else if (x < 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1381 x = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1382
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1383 if ((y + h + + 4) > scr_h)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1384 y = y - imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent;
2071
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1385 else
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1386 if (imhtml->tip_bit->font)
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1387 y = y + imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent;
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1388 else
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1389 y = y + font->ascent + font->descent;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1390
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1391 gtk_widget_set_usize (imhtml->tip_window, w, h);
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1392 gtk_widget_set_uposition (imhtml->tip_window, x, y);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1393 gtk_widget_show (imhtml->tip_window);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1394
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1395 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1396 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1397 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1398
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1399 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400 gtk_imhtml_motion_notify_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 GdkEventMotion *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1404 GdkModifierType state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1405 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409 if (event->is_hint)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 gdk_window_get_pointer (event->window, &x, &y, &state);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411 else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 state = event->state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1417 if (state & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419 gint height = vadj->page_size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 gint yy = y - vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422 if (((yy < 0) || (yy > height)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 (imhtml->scroll_timer == 0) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 (vadj->upper > vadj->page_size)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425 imhtml->scroll_timer = gtk_timeout_add (100,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426 (GtkFunction) scroll_timeout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1427 imhtml);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1428 diff = (yy < 0) ? (yy / 2) : ((yy - height) / 2);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 gtk_adjustment_set_value (vadj,
2337
e3939d21c2f0 [gaim-migrate @ 2350]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2188
diff changeset
1430 MIN (vadj->value + diff, vadj->upper - height));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433 if (imhtml->selection) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1434 struct line_info *chunk = imhtml->sel_endchunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436 imhtml->sel_endy = MAX (y, 0);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1437 if ((chunk == NULL) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1438 (x < chunk->x) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1439 (x > chunk->x + chunk->width) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1440 (y < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1441 (y > chunk->y + chunk->height))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1442 gtk_imhtml_select_bits (imhtml);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1443 else
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1444 gtk_imhtml_select_in_chunk (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 GList *urls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450 while (urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 uw = (struct url_widget *) urls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452 if ((x > uw->x) && (x < uw->x + uw->width) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1454 if (imhtml->tip_bit != uw->bit) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1455 imhtml->tip_bit = uw->bit;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1456 if (imhtml->tip_timer != 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1457 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1458 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1459 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1460 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1461 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1462 imhtml->tip_timer = gtk_timeout_add (TOOLTIP_TIMEOUT,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1463 gtk_imhtml_tip,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1464 imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1465 }
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1466 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window,
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1467 imhtml->hand_cursor);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 urls = g_list_next (urls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1474 if (imhtml->tip_timer) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1475 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1476 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1477 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1478 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1479 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1480 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1481 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1482 imhtml->tip_bit = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1483
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1484 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1486 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1487 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1488
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489 static gint
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1490 gtk_imhtml_leave_notify_event (GtkWidget *widget,
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1491 GdkEventCrossing *event)
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1492 {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1493 GtkIMHtml *imhtml = GTK_IMHTML (widget);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1494
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1495 if (imhtml->tip_timer) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1496 gtk_timeout_remove (imhtml->tip_timer);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1497 imhtml->tip_timer = 0;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1498 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1499 if (imhtml->tip_window) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1500 gtk_widget_destroy (imhtml->tip_window);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1501 imhtml->tip_window = NULL;
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 imhtml->tip_bit = NULL;
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 return TRUE;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1506 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1507
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1508 static void
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1509 menu_open_url (GtkObject *object,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1510 gpointer data)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1511 {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1512 struct url_widget *uw = data;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1513
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1514 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
1515 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1516
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1517 static void
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1518 menu_copy_link (GtkObject *object,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1519 gpointer data)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1520 {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1521 struct url_widget *uw = data;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1522 GtkIMHtml *imhtml = uw->imhtml;
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 if (imhtml->selected_text)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1525 g_string_free (imhtml->selected_text, TRUE);
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 gtk_imhtml_select_none (uw->imhtml);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1528
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1529 imhtml->selection = TRUE;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1530 imhtml->selected_text = g_string_new (uw->bit->url);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1531
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1532 gtk_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
1533 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1534
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1535 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536 gtk_imhtml_button_press_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1538 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1539 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1544 x = event->x + hadj->value;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1545 y = event->y + vadj->value;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1546
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 if (event->button == 1) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548 imhtml->sel_startx = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 imhtml->sel_starty = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1550 imhtml->selection = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1552 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1553
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1554 if (event->button == 3) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1555 GList *urls = imhtml->urls;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1556 struct url_widget *uw;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1557
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1558 while (urls) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1559 uw = urls->data;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1560 if ((x > uw->x) && (x < uw->x + uw->width) &&
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1561 (y > uw->y) && (y < uw->y + uw->height)) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1562 GtkWidget *menu = gtk_menu_new ();
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1563
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1564 GtkWidget *button = gtk_menu_item_new_with_label ("Open URL");
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1565 gtk_signal_connect (GTK_OBJECT (button), "activate",
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1566 GTK_SIGNAL_FUNC (menu_open_url), uw);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1567 gtk_menu_append (GTK_MENU (menu), button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1568 gtk_widget_show (button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1569
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1570 button = gtk_menu_item_new_with_label ("Copy Link Location");
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1571 gtk_signal_connect (GTK_OBJECT (button), "activate",
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1572 GTK_SIGNAL_FUNC (menu_copy_link), uw);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1573 gtk_menu_append (GTK_MENU (menu), button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1574 gtk_widget_show (button);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1575
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1576 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1577 3, event->time);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1578
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1579 if (imhtml->tip_timer) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1580 gtk_timeout_remove (imhtml->tip_timer);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1581 imhtml->tip_timer = 0;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1582 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1583 if (imhtml->tip_window) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1584 gtk_widget_destroy (imhtml->tip_window);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1585 imhtml->tip_window = NULL;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1586 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1587 imhtml->tip_bit = NULL;
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 return TRUE;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1590 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1591 urls = g_list_next (urls);
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 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1594
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1595 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1597
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1599 gtk_imhtml_button_release_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1600 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1603 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1606
1456
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1607 x = event->x + hadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1608 y = event->y + vadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1609
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1610 if ((event->button == 1) && imhtml->selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1611 if ((x == imhtml->sel_startx) && (y == imhtml->sel_starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1612 imhtml->sel_startx = imhtml->sel_starty = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1613 imhtml->selection = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1614 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 imhtml->sel_endy = MAX (y, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 gtk_imhtml_select_bits (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621 gtk_selection_owner_set (widget, GDK_SELECTION_PRIMARY, event->time);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623
1547
7b50a08090a2 [gaim-migrate @ 1557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1528
diff changeset
1624 if ((event->button == 1) && (imhtml->sel_startx == 0)) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1625 GList *urls = imhtml->urls;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1626 struct url_widget *uw;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1627
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1628 while (urls) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1629 uw = (struct url_widget *) urls->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1630 if ((x > uw->x) && (x < uw->x + uw->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1631 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1632 gtk_signal_emit (GTK_OBJECT (imhtml), signals [URL_CLICKED],
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1633 uw->bit->url);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1634 return TRUE;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1635 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1636 urls = g_list_next (urls);
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 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1639
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1640 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1641 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1642
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1643 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1644 gtk_imhtml_selection_get (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1645 GtkSelectionData *sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1646 guint sel_info,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1647 guint32 time)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1648 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1649 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1650 gchar *string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1651 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1652
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1653 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1654 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1655 g_return_if_fail (sel_data->selection == GDK_SELECTION_PRIMARY);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1656
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1657 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1658
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1659 g_return_if_fail (imhtml->selected_text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1660 g_return_if_fail (imhtml->selected_text->str != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1661
2188
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1662 if (imhtml->selected_text->len <= 0)
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1663 return;
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1664
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1665 string = g_strdup (imhtml->selected_text->str);
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1666 length = strlen (string);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1667
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1668 if (sel_info == TARGET_STRING) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1669 gtk_selection_data_set (sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1670 GDK_SELECTION_TYPE_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1671 8 * sizeof (gchar),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1672 (guchar *) string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1673 length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674 } else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1675 guchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1676 GdkAtom encoding;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1677 gint format;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1678 gint new_length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1679
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1680 gdk_string_to_compound_text (string, &encoding, &format, &text, &new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1681 gtk_selection_data_set (sel_data, encoding, format, text, new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1682 gdk_free_compound_text (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1683 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1684
2188
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1685 g_free (string);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1686 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1687
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 gtk_imhtml_selection_clear_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690 GdkEventSelection *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1691 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694 g_return_val_if_fail (widget != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1695 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 g_return_val_if_fail (event != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 g_return_val_if_fail (event->selection == GDK_SELECTION_PRIMARY, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699 if (!gtk_selection_clear (widget, event))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1700 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1703
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1704 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1705
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1706 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1707 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1708
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 static void
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1710 gtk_imhtml_adjustment_changed (GtkAdjustment *adjustment,
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1711 GtkIMHtml *imhtml)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1712 {
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1713 GtkLayout *layout = GTK_LAYOUT (imhtml);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1714
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1715 layout->xoffset = (gint) layout->hadjustment->value;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1716 layout->yoffset = (gint) layout->vadjustment->value;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1717
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1718 if (!GTK_WIDGET_MAPPED (imhtml) || !GTK_WIDGET_REALIZED (imhtml))
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1719 return;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1720
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1721 if (layout->freeze_count)
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1722 return;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1723
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1724 if (layout->yoffset < TOP_BORDER)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1725 gdk_window_clear_area (layout->bin_window, 0, 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1726 imhtml->xsize, TOP_BORDER - layout->yoffset);
1961
0a3edeba05b6 [gaim-migrate @ 1971]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1955
diff changeset
1727
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1728 gtk_imhtml_draw_exposed (imhtml);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1729 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1730
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1731 static void
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732 gtk_imhtml_set_scroll_adjustments (GtkLayout *layout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1735 {
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1736 gboolean need_adjust = FALSE;
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 g_return_if_fail (layout != NULL);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1739 g_return_if_fail (GTK_IS_IMHTML (layout));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1740
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1741 if (hadj)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1742 g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1743 else
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1744 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
1745 if (vadj)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1746 g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1747 else
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1748 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
1749
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1750 if (layout->hadjustment && (layout->hadjustment != hadj)) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1751 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->hadjustment), layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1752 gtk_object_unref (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1753 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1754
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1755 if (layout->vadjustment && (layout->vadjustment != vadj)) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1756 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->vadjustment), layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1757 gtk_object_unref (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1758 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1759
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1760 if (layout->hadjustment != hadj) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1761 layout->hadjustment = hadj;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1762 gtk_object_ref (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1763 gtk_object_sink (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1764
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1765 gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed",
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1766 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1767 need_adjust = TRUE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1768 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1769
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1770 if (layout->vadjustment != vadj) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1771 layout->vadjustment = vadj;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1772 gtk_object_ref (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1773 gtk_object_sink (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1774
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1775 gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed",
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1776 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1777 need_adjust = TRUE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1778 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1779
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1780 if (need_adjust)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1781 gtk_imhtml_adjustment_changed (NULL, GTK_IMHTML (layout));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1782 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1783
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1784 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1785 gtk_imhtml_class_init (GtkIMHtmlClass *class)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1786 {
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1787 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1788 GObjectClass *gobject_class;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1789 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1790 GtkObjectClass *object_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1791 GtkWidgetClass *widget_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1792 GtkLayoutClass *layout_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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 gobject_class = (GObjectClass*) class;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1796 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1797 object_class = (GtkObjectClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1798 widget_class = (GtkWidgetClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1799 layout_class = (GtkLayoutClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1800
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1801 parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803 signals [URL_CLICKED] =
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 gtk_signal_new ("url_clicked",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 GTK_RUN_FIRST,
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1806 GTK_CLASS_TYPE (object_class),
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1807 GTK_SIGNAL_OFFSET (GtkIMHtmlClass, url_clicked),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 gtk_marshal_NONE__POINTER,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809 GTK_TYPE_NONE, 1,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1810 GTK_TYPE_POINTER);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1812 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1813 gobject_class->finalize = gtk_imhtml_finalize;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1814 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1816
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1817 object_class->destroy = gtk_imhtml_destroy;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1818 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1819
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1820 widget_class->realize = gtk_imhtml_realize;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1821 #if !GTK_CHECK_VERSION(1,3,0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822 widget_class->draw = gtk_imhtml_draw;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1823 widget_class->draw_focus = gtk_imhtml_draw_focus;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1824 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1825 widget_class->style_set = gtk_imhtml_style_set;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1826 widget_class->expose_event = gtk_imhtml_expose_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1827 widget_class->size_allocate = gtk_imhtml_size_allocate;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1828 widget_class->motion_notify_event = gtk_imhtml_motion_notify_event;
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1829 widget_class->leave_notify_event = gtk_imhtml_leave_notify_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1830 widget_class->button_press_event = gtk_imhtml_button_press_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1831 widget_class->button_release_event = gtk_imhtml_button_release_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1832 widget_class->selection_get = gtk_imhtml_selection_get;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 widget_class->selection_clear_event = gtk_imhtml_selection_clear_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835 layout_class->set_scroll_adjustments = gtk_imhtml_set_scroll_adjustments;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1836 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1837
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1838 static gchar*
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1839 gtk_imhtml_get_font_name (GdkFont *font)
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1840 {
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1841 #if GTK_CHECK_VERSION(1,3,0)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1842 return "--*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*";
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1843 #else
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1844 GdkFontPrivate *fontpriv = (GdkFontPrivate *) font;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1845 return fontpriv->names->data;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1846 #endif
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1847 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1848
2694
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1849 #define TRY_FONT tmp = g_strjoinv ("-", newvals); \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1850 if (default_font->type == GDK_FONT_FONT) \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1851 ret_font = gdk_font_load (tmp); \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1852 else \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1853 ret_font = gdk_fontset_load (tmp); \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1854 g_free (tmp); \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1855 if (ret_font) { \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1856 g_strfreev (xflds); \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1857 g_strfreev (names); \
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1858 return ret_font; \
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1859 }
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1860
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1861
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1862 static GdkFont*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1863 gtk_imhtml_font_load (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1864 gchar *name,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1865 gboolean bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1866 gboolean italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1867 gint fontsize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1868 {
2691
b5698b2cad87 [gaim-migrate @ 2704]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2690
diff changeset
1869 GdkFont *default_font = imhtml->default_font;
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1870 gchar *default_name;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1871 gchar **xflds;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1872
2693
2c746e70f2b3 [gaim-migrate @ 2706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2691
diff changeset
1873 gchar *newvals[16];
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1874 gint i;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1875 gchar **names;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1876 gchar fs[10];
2694
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1877
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1878 gchar *tmp;
91f4da998025 [gaim-migrate @ 2707]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2693
diff changeset
1879 GdkFont *ret_font;
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1880
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1881 if (!name && !bold && !italics && !fontsize)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1882 return gdk_font_ref (default_font);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1883
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1884 default_name = gtk_imhtml_get_font_name (default_font);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1885 xflds = g_strsplit (default_name, "-", -1);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1886
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1887 #define NAME 2
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1888 #define BOLD 3
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1889 #define ITALICS 4
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1890 #define SIZE 6
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1891 #define PTSZ 7
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1892 #define END 15
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1893
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1894 if (name)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1895 names = g_strsplit (name, ",", -1);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1896 else {
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1897 names = g_new0 (gchar *, 2);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1898 names [0] = g_strdup (xflds [NAME]);
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1899 }
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1900
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1901 for (i = 0; xflds [i]; i++)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1902 newvals [i] = xflds [i];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1903
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1904 if (bold)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1905 newvals [BOLD] = "bold";
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1906 if (italics)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1907 newvals [ITALICS] = "i";
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1908 if (fontsize) {
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1909 g_snprintf (fs, sizeof (fs), "%d", font_sizes [MIN (fontsize, MAX_SIZE) - 1]);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1910 newvals [SIZE] = fs;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1911 newvals [PTSZ] = "";
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1912 }
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1913 newvals [END] = NULL;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1914
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1915 TRY_FONT;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1916
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1917 for (i = 0; italics && names [i]; i++) {
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1918 newvals [NAME] = names [i];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1919
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1920 newvals [ITALICS] = "o";
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1921 TRY_FONT;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1922
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1923 newvals [ITALICS] = xflds [ITALICS];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1924 TRY_FONT;
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1925 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1926
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1927 for (i = 0; fontsize && names [i]; i++) {
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1928 newvals [NAME] = names [i];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1929
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1930 if (xflds [PTSZ][0]) {
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1931 g_snprintf (fs, sizeof (fs), "%d",
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1932 font_sizes [MIN (fontsize, MAX_SIZE) - 1] / 10);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1933 newvals [PTSZ] = fs;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1934 newvals [SIZE] = "";
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1935 TRY_FONT;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1936
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1937 newvals [PTSZ] = xflds [PTSZ];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1938 } else
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1939 newvals [SIZE] = xflds [SIZE];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1940 TRY_FONT;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1941 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1942
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1943 for (i = 0; bold && names [i]; i++) {
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1944 newvals [NAME] = names [i];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1945
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1946 newvals [BOLD] = xflds [BOLD];
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1947 TRY_FONT;
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1948 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
1949
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1950 #undef NAME
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1951 #undef BOLD
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1952 #undef ITALICS
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1953 #undef SIZE
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1954 #undef PTSZ
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1955 #undef REG
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1956 #undef ENC
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1957 #undef END
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1958
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1959 g_strfreev (xflds);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1960 g_strfreev (names);
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1961
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
1962 return gdk_font_ref (default_font);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1964
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1965 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966 gtk_imhtml_init (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1967 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 static const GtkTargetEntry targets [] = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969 { "STRING", 0, TARGET_STRING },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970 { "TEXT", 0, TARGET_TEXT },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1971 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1972 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1977 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 GtkType
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 gtk_imhtml_get_type (void)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1984 static GtkType imhtml_type = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1985
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1986 if (!imhtml_type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1987 static const GtkTypeInfo imhtml_info = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1988 "GtkIMHtml",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1989 sizeof (GtkIMHtml),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1990 sizeof (GtkIMHtmlClass),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1991 (GtkClassInitFunc) gtk_imhtml_class_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992 (GtkObjectInitFunc) gtk_imhtml_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1993 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1995 NULL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1996 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1997
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1998 imhtml_type = gtk_type_unique (GTK_TYPE_LAYOUT, &imhtml_info);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1999 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2000
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2002 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2003
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2004 static void
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2005 gtk_imhtml_init_smileys (GtkIMHtml *imhtml)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2010 imhtml->smiley_data = gtk_smiley_tree_new ();
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2011
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012 gtk_imhtml_associate_smiley (imhtml, ":)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2013 gtk_imhtml_associate_smiley (imhtml, ":-)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2014
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015 gtk_imhtml_associate_smiley (imhtml, ":(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2016 gtk_imhtml_associate_smiley (imhtml, ":-(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2017
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018 gtk_imhtml_associate_smiley (imhtml, ";)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2019 gtk_imhtml_associate_smiley (imhtml, ";-)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2020
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2021 gtk_imhtml_associate_smiley (imhtml, ":-p", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2022 gtk_imhtml_associate_smiley (imhtml, ":-P", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2023
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2024 gtk_imhtml_associate_smiley (imhtml, "=-O", scream_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2025 gtk_imhtml_associate_smiley (imhtml, ":-*", kiss_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2026 gtk_imhtml_associate_smiley (imhtml, ">:o", yell_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2027 gtk_imhtml_associate_smiley (imhtml, "8-)", smile8_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2028 gtk_imhtml_associate_smiley (imhtml, ":-$", moneymouth_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2029 gtk_imhtml_associate_smiley (imhtml, ":-!", burp_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2030 gtk_imhtml_associate_smiley (imhtml, ":-[", embarrassed_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2031 gtk_imhtml_associate_smiley (imhtml, ":'(", cry_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2032
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2033 gtk_imhtml_associate_smiley (imhtml, ":-/", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2034 gtk_imhtml_associate_smiley (imhtml, ":-\\", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2035
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2036 gtk_imhtml_associate_smiley (imhtml, ":-X", crossedlips_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2037 gtk_imhtml_associate_smiley (imhtml, ":-D", bigsmile_xpm);
2583
ce3df2c43f46 [gaim-migrate @ 2596]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2556
diff changeset
2038 gtk_imhtml_associate_smiley (imhtml, ":-d", bigsmile_xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2039 gtk_imhtml_associate_smiley (imhtml, "O:-)", angel_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2040 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2041
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2042 GtkWidget*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2043 gtk_imhtml_new (GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2044 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2045 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2046 GtkIMHtml *imhtml = gtk_type_new (GTK_TYPE_IMHTML);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2047
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2048 gtk_imhtml_set_adjustments (imhtml, hadj, vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2049
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2050 imhtml->bits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2051 imhtml->urls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2052
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2053 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2054 imhtml->y = TOP_BORDER;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2055 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2056 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2057 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2061
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2062 imhtml->img = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2064 imhtml->smileys = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2065 imhtml->comments = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2066
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2067 gtk_imhtml_init_smileys (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2068
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2069 return GTK_WIDGET (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2070 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2071
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2072 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2073 gtk_imhtml_set_adjustments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2074 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2075 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2076 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2077 gtk_layout_set_hadjustment (GTK_LAYOUT (imhtml), hadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2078 gtk_layout_set_vadjustment (GTK_LAYOUT (imhtml), vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2079 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2080
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2081 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2082 gtk_imhtml_set_defaults (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2083 GdkFont *font,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2084 GdkColor *fg_color,
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2085 GdkColor *bg_color)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2086 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2087 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2088 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2089
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2090 if (font) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2091 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2092 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2093 imhtml->default_font = gdk_font_ref (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2094 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2095
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2096 if (fg_color) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2097 if (imhtml->default_fg_color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2098 gdk_color_free (imhtml->default_fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2099 imhtml->default_fg_color = gdk_color_copy (fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2100 }
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2101
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2102 if (bg_color) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2103 if (imhtml->default_bg_color)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2104 gdk_color_free (imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2105 imhtml->default_bg_color = gdk_color_copy (bg_color);
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
2106 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
2107 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2108 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2109
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2110 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2111 gtk_imhtml_set_img_handler (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2112 GtkIMHtmlImage handler)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2113 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2114 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2115 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2116
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2117 imhtml->img = handler;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2118 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2119
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2120 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2121 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2122 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2123 gchar **xpm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2124 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2125 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2126 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2127 g_return_if_fail (text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2128
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2129 if (xpm == NULL)
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2130 gtk_smiley_tree_remove (imhtml->smiley_data, text);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2131 else
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2132 gtk_smiley_tree_insert (imhtml->smiley_data, text, xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2133 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2134
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2135 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2136 new_line (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2137 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2138 GList *last = g_list_last (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2139 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2140
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2141 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2142 li = last->data;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2143 if (li->x + li->width != imhtml->xsize)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2144 li->width = imhtml->xsize - li->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2145 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2146
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2147 last = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2148 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2149 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2150 if (li->height < MIN_HEIGHT) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2151 while (last) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2152 gint diff;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2153 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2154 diff = MIN_HEIGHT - li->height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2155 li->height = MIN_HEIGHT;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2156 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2157 last = g_list_next (last);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2158 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2159 imhtml->llheight = MIN_HEIGHT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2160 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2161 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2162
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2163 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2164 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2165
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2166 imhtml->x = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2167 imhtml->y += imhtml->llheight;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2168 imhtml->llheight = 0;
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2169 imhtml->llascent = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2171
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2172 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2173 backwards_update (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2174 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2175 gint height,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2176 gint ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2177 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2178 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2179 GList *ls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2180 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2181 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2182
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2183 if (height > imhtml->llheight) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2184 diff = height - imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2185
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2186 ls = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2187 while (ls) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2188 li = ls->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2189 li->height += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2190 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2191 li->ascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2192 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2193 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2194 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2195 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2196
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2197 ls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2198 while (ls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2199 uw = ls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2200 if (uw->y + diff > imhtml->y)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2201 uw->y += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2202 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2203 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2204
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2205 imhtml->llheight = height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2206 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207 imhtml->llascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2209 imhtml->llascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2211 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2212
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2213 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2214 add_text_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2215 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2216 gchar *text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2217 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2218 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2219 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2221
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2222 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2223 width = gdk_string_width (bit->font, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2224 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2225 width = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2226
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2227 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2228 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2229 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2230 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2232 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233 li->ascent = MAX (imhtml->llascent, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236 li->text = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2237 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 if (bit->url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2242 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2244 uw->height = imhtml->llheight;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
2245 uw->imhtml = imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
2246 uw->bit = bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2248 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2250 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2251 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2254 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2255 add_img_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2258 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2262 gdk_window_get_size (bit->pm, &width, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2263
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2264 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2265 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2267 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2268 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2269 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2270 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2271
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272 if (bit->url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277 uw->height = imhtml->llheight;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
2278 uw->imhtml = imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
2279 uw->bit = bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2283 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2284 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2287 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290 gtk_imhtml_draw_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2292 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 gint width, height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297 g_return_if_fail (bit != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 if ( (bit->type == TYPE_TEXT) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300 ((bit->type == TYPE_SMILEY) && !imhtml->smileys) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 ((bit->type == TYPE_COMMENT) && imhtml->comments)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 gchar *copy = g_strdup (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303 gint pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2304 gboolean seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307 height = bit->font->ascent + bit->font->descent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308 width = gdk_string_width (bit->font, bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2310 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2311 gint remain = imhtml->xsize - imhtml->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2312 while (gdk_text_width (bit->font, copy, pos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313 if (copy [pos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 pos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2317 if (seenspace) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318 while (copy [pos - 1] != ' ') pos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320 tmp = g_strndup (copy, pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2324 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2328 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2329
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2330 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2331
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2332 while (pos < strlen (bit->text)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333 width = gdk_string_width (bit->font, copy + pos);
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2334 if (imhtml->x + width > imhtml->xsize) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335 gint newpos = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2336 gint remain = imhtml->xsize - imhtml->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 while (gdk_text_width (bit->font, copy + pos, newpos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338 if (copy [pos + newpos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2340 newpos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2343 if (seenspace)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2344 while (copy [pos + newpos - 1] != ' ') newpos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2345
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2346 if (newpos == 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2348
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 tmp = g_strndup (copy + pos, newpos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2350 pos += newpos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2352 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2354
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2355 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2358 tmp = g_strdup (copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2360 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2361 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2362
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2363 pos = strlen (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2364
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2365 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2367 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 } else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2371 gdk_window_get_size (bit->pm, &width, &height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2373 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 new_line (imhtml);
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2375 else
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2376 backwards_update (imhtml, bit, height, 0);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2377
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2378 add_img_renderer (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 } else if (bit->type == TYPE_BR) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 } else if (bit->type == TYPE_SEP) {
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2383 struct line_info *li;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2384 if (imhtml->llheight)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 new_line (imhtml);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2386
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2387 li = g_new0 (struct line_info, 1);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2388 li->x = imhtml->x;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2389 li->y = imhtml->y;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2390 li->width = imhtml->xsize;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2391 li->height = HR_HEIGHT * 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2392 li->ascent = 0;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2393 li->text = NULL;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2394 li->bit = bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2395
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2396 bit->chunks = g_list_append (bit->chunks, li);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2397
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 imhtml->llheight = HR_HEIGHT * 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2402 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2403
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2404 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405 gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2407 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2408 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2410
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 imhtml->smileys = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2414 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2415 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 gtk_imhtml_show_comments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2421 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2422 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2423
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424 imhtml->comments = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2427 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2428 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 static GdkColor *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 gtk_imhtml_get_color (const gchar *color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433 GdkColor c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2435 if (!gdk_color_parse (color, &c))
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2436 return NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
2438 return gdk_color_copy (&c);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2440
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2441 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2442 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2443 const gchar *text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2444 {
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2445 return gtk_smiley_tree_lookup (imhtml->smiley_data, text);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2446 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2447
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2448 static GtkIMHtmlBit *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2449 gtk_imhtml_new_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 gint type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2451 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 gint bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 gint italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454 gint underline,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 gint strike,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456 FontDetail *font,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2457 GdkColor *bg,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2458 gchar *url,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2459 gint pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2460 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461 GtkIMHtmlBit *bit = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2463 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2464 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2465
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2466 if ((type == TYPE_TEXT) && ((text == NULL) || (strlen (text) == 0)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2467 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2468
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2469 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2470 bit->type = type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2471
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2472 if ((text != NULL) && (strlen (text) != 0))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 bit->text = g_strdup (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2475 if ((font != NULL) || bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2476 if (font && (bold || italics || font->size || font->face || pre)) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2477 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2478 bit->font = gtk_imhtml_font_load (imhtml, "courier", bold, italics, font->size);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2479 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2480 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
2481 }
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2482 } else if (bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2483 if (pre) {
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2484 bit->font = gtk_imhtml_font_load (imhtml, "courier", bold, italics, 0);
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2485 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2486 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2487 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2488 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2489
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2490 if (font && (type != TYPE_BR)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 if (font->fore != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 bit->fore = gdk_color_copy (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 if (font->back != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495 bit->back = gdk_color_copy (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2496 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2499 if (((bit->type == TYPE_TEXT) || (bit->type == TYPE_SMILEY) || (bit->type == TYPE_COMMENT)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2500 (bit->font == NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2501 bit->font = gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 if (bg != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504 bit->bg = gdk_color_copy (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2506 bit->underline = underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2507 bit->strike = strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2508
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2509 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512 if (type == TYPE_SMILEY) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2513 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2514
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515 if ((font != NULL) && (font->back != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516 clr = font->back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2517 else
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2518 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522 clr,
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2523 gtk_smiley_tree_image (imhtml->smiley_data, text));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2525
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2526 return bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2527 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2528
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2529 #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
2530 fonts ? fonts->data : NULL, bg, url, pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2531 #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
2532 fonts ? fonts->data : NULL, bg, url, pre)
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2533 #define NEW_SEP_BIT gtk_imhtml_new_bit (imhtml, TYPE_SEP, NULL, 0, 0, 0, 0, NULL, bg, NULL, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2534 #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
2535 fonts ? fonts->data : NULL, bg, NULL, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2536 #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
2537 fonts ? fonts->data : NULL, bg, url, pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2538
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2539 #define NEW_BIT(bit) { GtkIMHtmlBit *tmp = bit; if (tmp != NULL) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2540 newbits = g_list_append (newbits, tmp); }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2541
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2542 #define UPDATE_BG_COLORS \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543 { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2544 GdkColormap *cmap; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 GList *rev; \
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2546 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2547 rev = g_list_last (newbits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2548 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2549 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2550 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2551 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2552 bit->bg = gdk_color_copy (bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2553 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2554 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2556 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2557 if (!rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558 rev = g_list_last (imhtml->bits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2559 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2560 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2561 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2562 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2563 bit->bg = gdk_color_copy (bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2564 gdk_color_alloc (cmap, bit->bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2565 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2566 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2567 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2568 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2569 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2570 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2571
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2572 static gboolean
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2573 is_amp_escape (const gchar *string,
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2574 gchar *replace,
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2575 gint *length)
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2576 {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2577 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2578 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2579 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2580
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2581 if (!g_strncasecmp (string, "&amp;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2582 *replace = '&';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2583 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2584 } else if (!g_strncasecmp (string, "&lt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2585 *replace = '<';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2586 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2587 } else if (!g_strncasecmp (string, "&gt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2588 *replace = '>';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2589 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2590 } else if (!g_strncasecmp (string, "&nbsp;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2591 *replace = ' ';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2592 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2593 } else if (!g_strncasecmp (string, "&copy;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2594 *replace = '©';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2595 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2596 } else if (!g_strncasecmp (string, "&quot;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2597 *replace = '\"';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2598 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2599 } else if (!g_strncasecmp (string, "&reg;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2600 *replace = '®';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2601 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2602 } else if (*(string + 1) == '#') {
2022
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
2603 guint pound = 0;
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
2604 if (sscanf (string, "&#%u;", &pound) == 1) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2605 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2606 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2607 *replace = (gchar)pound;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2608 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2609 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2610 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2611 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2612 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2613 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2614 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2615 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2616 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2617
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2618 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2619 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2620
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2621 GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2622 gtk_imhtml_append_text (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2623 const gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2624 GtkIMHtmlOptions options)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2625 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2626 const gchar *c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2627 gboolean intag = FALSE;
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2628 gint tagquote = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2629 gboolean incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2630 gchar *ws;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2631 gchar *tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2632 gint wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2633 gint tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2634 int smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2635 GList *newbits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2636
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2637 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2638 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2639 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2640 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2641 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2642 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2643 title = 0,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2644 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2645 GSList *fonts = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2646 GdkColor *bg = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2647 gchar *url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2648
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2649 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2650 gboolean scrolldown = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2651
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2652 GString *retval = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2653
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2654 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2655 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2656 g_return_val_if_fail (text != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2657
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2658 if (options & GTK_IMHTML_RETURN_LOG)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2659 retval = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2660
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2661 vadj = GTK_LAYOUT (imhtml)->vadjustment;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2662 if ((vadj->value < imhtml->y - GTK_WIDGET (imhtml)->allocation.height) &&
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2663 (vadj->upper >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2664 scrolldown = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2665
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2666 c = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2667 ws = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2668 tag = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2669
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2670 ws [0] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2671
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2672 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2673 if (*c == '<') {
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2674 if (intag && (tagquote != 1)) {
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2675 char *d;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2676 tag [tpos] = 0;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2677 d = tag;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2678 while (*d) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2679 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2680 ws [wpos] = 0;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2681 wpos = 0;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2682 NEW_BIT (NEW_TEXT_BIT);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2683 g_snprintf (ws, smilelen + 1, "%s", d);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2684 NEW_BIT (NEW_SMILEY_BIT);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2685 d += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2686 } else if (*d == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2687 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2688 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2689 if (is_amp_escape (d, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2690 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2691 d += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2692 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2693 ws [wpos++] = *d++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2694 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2695 } else if (*d == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2696 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2697 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2698 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2699 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2700 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2701 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2702 d++;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2703 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2704 ws [wpos++] = *d++;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2705 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2706 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2707 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2708 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2709
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2710 if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2711 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2712 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2713 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2714
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2715 if (!g_strncasecmp (c, "<!--", strlen ("<!--"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2716 if (!(options & GTK_IMHTML_NO_COMMENTS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2717 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2718 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2719 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2720 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2721 incomment = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2722 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2723 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2724 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2725 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2726 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2727 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2728 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2729 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2730
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2731 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2732 intag = TRUE;
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2733 tagquote = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2734 } else if (incomment && (*c == '-') && !g_strncasecmp (c, "-->", strlen ("-->"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2735 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2736 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2737 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2738 tmp = g_strdup (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2739 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2740 strcat (ws, tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2741 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2742 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2743 strcat (ws, tmp + strlen ("<!--"));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2744 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2745 NEW_BIT (NEW_COMMENT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2746 incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2747 c += strlen ("-->");
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2748 } else if (*c == '>' && intag && (tagquote != 1)) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2749 gboolean got_tag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2750 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2751 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2752 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2753
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2754 if (!g_strcasecmp (tag, "<B>") || !g_strcasecmp (tag, "<BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2755 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2756 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2757 bold++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2758 } else if (!g_strcasecmp (tag, "</B>") || !g_strcasecmp (tag, "</BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2759 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2760 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2761 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2762 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2763 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2764 } else if (!g_strcasecmp (tag, "<I>") || !g_strcasecmp (tag, "<ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2765 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2766 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2767 italics++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2768 } else if (!g_strcasecmp (tag, "</I>") || !g_strcasecmp (tag, "</ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2769 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2770 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2771 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2772 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2773 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2774 } else if (!g_strcasecmp (tag, "<U>") || !g_strcasecmp (tag, "<UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2775 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2776 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2777 underline++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2778 } else if (!g_strcasecmp (tag, "</U>") || !g_strcasecmp (tag, "</UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2779 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2780 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2781 if (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2782 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2783 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2784 } else if (!g_strcasecmp (tag, "<S>") || !g_strcasecmp (tag, "<STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2785 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2786 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2787 strike++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2788 } else if (!g_strcasecmp (tag, "</S>") || !g_strcasecmp (tag, "</STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2789 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2790 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2791 if (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2792 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2793 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2794 } else if (!g_strcasecmp (tag, "<SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2795 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2796 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2797 sub++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2798 } else if (!g_strcasecmp (tag, "</SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2799 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2800 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2801 if (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2802 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2803 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2804 } else if (!g_strcasecmp (tag, "<SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2805 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2806 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2807 sup++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2808 } else if (!g_strcasecmp (tag, "</SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2809 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2810 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2811 if (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2812 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2813 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2814 } else if (!g_strcasecmp (tag, "<PRE>")) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2815 got_tag = TRUE;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2816 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2817 pre++;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2818 } else if (!g_strcasecmp (tag, "</PRE>")) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2819 got_tag = TRUE;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2820 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2821 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2822 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2823 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 } else if (!g_strcasecmp (tag, "<TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2825 if (options & GTK_IMHTML_NO_TITLE) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2826 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2827 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2828 title++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2829 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2830 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2831 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2832 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2833 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2834 } else if (!g_strcasecmp (tag, "</TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2835 if (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2836 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2837 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2838 ws [wpos] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2839 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2840 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2841 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2842 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2843 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2844 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2845 } else if (!g_strcasecmp (tag, "<BR>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2846 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2847 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2848 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2849 } else if (!g_strcasecmp (tag, "<HR>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2850 !g_strncasecmp (tag, "<HR ", strlen ("<HR "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2851 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2852 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2853 NEW_BIT (NEW_SEP_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2854 } else if (!g_strncasecmp (tag, "<FONT ", strlen ("<FONT "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2855 gchar *t, *e, *a, *value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2856 FontDetail *font = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2857 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2858 gint saw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2859 gint i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2860
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861 t = tag + strlen ("<FONT ");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2862
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2863 while (*t != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2864 value = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2865 saw = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2866
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2867 while (g_strncasecmp (t, "COLOR=", strlen ("COLOR="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2868 && g_strncasecmp (t, "BACK=", strlen ("BACK="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869 && g_strncasecmp (t, "FACE=", strlen ("FACE="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2870 && g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2871 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2872 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2873 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2874 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2875 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2876 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2877 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2878 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2879 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2880
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2881 if (!g_strncasecmp (t, "COLOR=", strlen ("COLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2882 t += strlen ("COLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2883 saw = 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2884 } else if (!g_strncasecmp (t, "BACK=", strlen ("BACK="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2885 t += strlen ("BACK=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2886 saw = 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2887 } else if (!g_strncasecmp (t, "FACE=", strlen ("FACE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2888 t += strlen ("FACE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2889 saw = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2890 } else if (!g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2891 t += strlen ("SIZE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2892 saw = 4;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2893 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2894
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2895 if (!saw)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2896 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2897
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2898 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2899 e = a = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2900 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2901 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2902 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2903 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2904 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2905 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2906 *t = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2907 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2908 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2909 e = a = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2910 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2911 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2912 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2913 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2914 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2915 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2916
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2917 if (value == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2918 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2919
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2920 if (font == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2921 font = g_new0 (FontDetail, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2922
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2923 switch (saw) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2924 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2925 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2926 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2927 if ( (font->fore == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2928 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2929 font->fore = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2930 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2931 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2932 case 2:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2933 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2934 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2935 if ( (font->back == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2936 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2937 font->back = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2938 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2939 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2940 case 3:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2941 if ( (font->face == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2942 !(options & GTK_IMHTML_NO_FONTS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2943 font->face = g_strdup (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2944 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2945 case 4:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2946 if ((font->size != 0) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2947 (options & GTK_IMHTML_NO_SIZES))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2948 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2949
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2950 if (isdigit ((gint) value [0])) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2951 for (i = 0; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2952 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2953 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2954 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2955 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2956
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2957 sscanf (value, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2958 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2959 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2960
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2961 if ((value [0] == '+') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2962 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2963 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2964 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2965 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2966 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2967
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2968 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2969 font->size += 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2970 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2971 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2972
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2973 if ((value [0] == '-') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2974 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2975 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2976 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2977 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2978 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2979
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2980 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2981 font->size = MIN (font->size, 2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2982 font->size = 3 - font->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2983 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2984 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2985
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2986 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2987 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2988
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2989 g_free (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2990 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2991
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
2992 if (!font || !(font->size || font->face || font->fore || font->back)) {
2622
733471f39ac9 [gaim-migrate @ 2635]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2621
diff changeset
2993 g_free (font);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2994 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2995 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2996 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2997 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2998
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
2999 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3000
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3001 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3002 FontDetail *oldfont = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3003 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3004 font->size = oldfont->size;
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3005 if (!font->face && oldfont->face)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3006 font->face = g_strdup (oldfont->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3007 if (!font->fore && oldfont->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3008 font->fore = gdk_color_copy (oldfont->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3009 if (!font->back && oldfont->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3010 font->back = gdk_color_copy (oldfont->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3011 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3012 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3013 font->size = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3014 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3015
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3016 fonts = g_slist_prepend (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3017 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3018 } else if (!g_strcasecmp (tag, "</FONT>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3019 FontDetail *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3020
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3021 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3022 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3023 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3024 font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3025 fonts = g_slist_remove (fonts, font);
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3026 if (font->face)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3027 g_free (font->face);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3028 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3029 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3030 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3031 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3032 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3033 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3034 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3035 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3036 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3037 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3038 } else if (!g_strncasecmp (tag, "<BODY ", strlen ("<BODY "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3039 gchar *t, *e, *color = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3040 GdkColor *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3041
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3042 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3043
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3044 if (!(options & GTK_IMHTML_NO_COLOURS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3045 t = tag + strlen ("<BODY");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3046 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3047 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3048 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3049 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3050 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3051 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3052 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3053 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3054 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3055 } while (g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3056
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3057 if (!g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3058 t += strlen ("BGCOLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3059 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3060 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3061 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3062 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3063 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3064 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3065 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3066 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3067 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3068 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3069 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3070 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3071 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3072 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3073
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3074 if (color != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3075 tmp = gtk_imhtml_get_color (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3076 g_free (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3077 if (tmp != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3078 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3079 bg = tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3080 UPDATE_BG_COLORS;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3081 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3082 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3083 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3084 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3085 } else if (!g_strncasecmp (tag, "<A ", strlen ("<A "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3086 gchar *t, *e;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3087
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3088 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3089 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3090
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3091 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3092 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3093 url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3094
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3095 t = tag + strlen ("<A");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3096 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3097 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3098 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3099 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3100 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3101 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3102 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3103 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3104 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3105 } while (g_strncasecmp (t, "HREF=", strlen ("HREF=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3106
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3107 if (!g_strncasecmp (t, "HREF=", strlen ("HREF="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3108 t += strlen ("HREF=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3109 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3110 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3111 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3112 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3113 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3114 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3115 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3116 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3117 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3118 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3119 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3120 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3121 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3122 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3123 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3124 } else if (!g_strcasecmp (tag, "</A>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3125 if (url != NULL) {
1524
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3126 got_tag = TRUE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3127 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3128 g_free (url);
1524
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3129 url = NULL;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3130 } else {
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3131 intag = FALSE;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3132 tpos = 0;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
3133 continue;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3134 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3135 } else if (!g_strncasecmp (tag, "<IMG ", strlen ("<IMG "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3136 gchar *t, *e, *src = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3137 gchar *copy = g_strdup (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3138 gchar **xpm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3139 GdkColor *clr = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3140 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3141
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3142 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3143 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3144
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3145 if (imhtml->img == NULL) {
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3146 ws [wpos] = 0;
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3147 strcat (ws, copy);
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3148 wpos = strlen (ws);
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3149 g_free (copy);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3150 continue;
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3151 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3152
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3153 t = tag + strlen ("<IMG");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3154 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3155 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3156 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3157 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3158 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3159 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3160 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3161 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3162 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3163 } while (g_strncasecmp (t, "SRC=", strlen ("SRC=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3164
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3165 if (!g_strncasecmp (t, "SRC=", strlen ("SRC="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3166 t += strlen ("SRC=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3167 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3168 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3169 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3170 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3171 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3172 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3173 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3174 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3175 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3176 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3177 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3178 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3179 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3180 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3181 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3182
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3183 if (src == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3184 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3185 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3186 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3187 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3188 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3189 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3190
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3191 xpm = (* imhtml->img) (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3192 if (xpm == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3193 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3194 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3195 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3196 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3197 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3198 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3199 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3200
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3201 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3202
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3203 if (!fonts || ((clr = ((FontDetail *) fonts->data)->back) == NULL))
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
3204 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3205
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3206 if (!GTK_WIDGET_REALIZED (imhtml))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3207 gtk_widget_realize (GTK_WIDGET (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3208
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3209 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3210 bit->type = TYPE_IMG;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3211 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3212 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3213 clr,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3214 xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3215 if (url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3216 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3217
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3218 NEW_BIT (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3219
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3220 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3221
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3222 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3223 } else if (!g_strcasecmp (tag, "<P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3224 !g_strcasecmp (tag, "</P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3225 !g_strncasecmp (tag, "<P ", strlen ("<P ")) ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
3226 !g_strcasecmp (tag, "<H3>") ||
1473
38e8391aa563 [gaim-migrate @ 1483]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1472
diff changeset
3227 !g_strncasecmp (tag, "<H3 ", strlen ("<H3 ")) ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
3228 !g_strcasecmp (tag, "</H3>") ||
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3229 !g_strcasecmp (tag, "<HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3230 !g_strcasecmp (tag, "</HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3231 !g_strcasecmp (tag, "<BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3232 !g_strcasecmp (tag, "</BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3233 !g_strcasecmp (tag, "<FONT>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3234 !g_strcasecmp (tag, "<HEAD>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3235 !g_strcasecmp (tag, "</HEAD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3236 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3237 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3238 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3239 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3240
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3241 if (!got_tag) {
1463
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3242 char *d;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3243 tag [tpos] = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3244 d = tag;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3245 while (*d) {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3246 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3247 ws [wpos] = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3248 wpos = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3249 NEW_BIT (NEW_TEXT_BIT);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3250 g_snprintf (ws, smilelen + 1, "%s", d);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3251 NEW_BIT (NEW_SMILEY_BIT);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3252 d += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3253 } else if (*d == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3254 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3255 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3256 if (is_amp_escape (d, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3257 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3258 d += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3259 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3260 ws [wpos++] = *d++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3261 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3262 } else if (*d == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3263 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3264 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3265 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3266 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3267 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3268 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3269 d++;
1463
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3270 } else {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3271 ws [wpos++] = *d++;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3272 }
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3273 }
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
3274 tpos = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3275 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3276 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3277 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3278 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3279 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3280 } else if (*c == '&' && !intag) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3281 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3282 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3283 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3284 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3285 c += length;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3286 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3287 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3288 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3289 } else if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3290 if (*c == '\"')
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
3291 tagquote++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3292 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3293 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3294 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3295 } else if (((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3296 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3297 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3298 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3299 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3300 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3301 c += smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3302 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3303 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3304 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3305 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3306 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3307 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3308 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3309 c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3310 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3311 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3312 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3313 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3314
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3315 if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3316 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3317 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3318 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3319 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3320 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3321 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3322 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3323 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3324 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3325 c += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3326 } else if (*c == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3327 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3328 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3329 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3330 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3331 c += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3332 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3333 ws [wpos++] = *c++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3334 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3335 } else if (*c == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3336 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3337 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3338 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3339 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3340 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3341 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3342 c++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3343 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3344 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3345 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3346 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3347 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3348 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3349 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3350 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3351 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3352 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3353 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3354 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3355 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3356 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3357 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3358 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3359 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3360 c += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3361 } else if (*c == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3362 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3363 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3364 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3365 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3366 c += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3367 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3368 ws [wpos++] = *c++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3369 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3370 } else if (*c == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3371 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3372 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3373 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3374 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3375 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3376 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
3377 c++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3378 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3379 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3380 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3381 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3382 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3383
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3384 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3385 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3386
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3387 while (newbits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3388 GtkIMHtmlBit *bit = newbits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3389 imhtml->bits = g_list_append (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3390 newbits = g_list_remove (newbits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3391 gtk_imhtml_draw_bit (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3392 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3393
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3394 GTK_LAYOUT (imhtml)->height = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3395 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3396 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
3397
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3398 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3399
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3400 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3401 if (!(options & GTK_IMHTML_NO_SCROLL) &&
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3402 scrolldown &&
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3403 (imhtml->y >= MAX (1,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3404 (GTK_WIDGET (imhtml)->allocation.height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3405 (GTK_WIDGET (imhtml)->style->ythickness + BORDER_SIZE) * 2))))
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3406 gtk_adjustment_set_value (vadj, imhtml->y -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3407 MAX (1, (GTK_WIDGET (imhtml)->allocation.height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3408 (GTK_WIDGET (imhtml)->style->ythickness +
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3409 BORDER_SIZE) * 2)));
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3410 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3411 if (!(options & GTK_IMHTML_NO_SCROLL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3412 scrolldown &&
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3413 (imhtml->y >= MAX (1,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3414 (GTK_WIDGET (imhtml)->allocation.height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3415 (GTK_WIDGET (imhtml)->style->klass->ythickness + BORDER_SIZE) * 2))))
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3416 gtk_adjustment_set_value (vadj, imhtml->y -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3417 MAX (1, (GTK_WIDGET (imhtml)->allocation.height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3418 (GTK_WIDGET (imhtml)->style->klass->ythickness +
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3419 BORDER_SIZE) * 2)));
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3420 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3421
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3422 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3423 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3424 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3425 retval = g_string_append (retval, "</A>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3426 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3427 if (bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3428 gdk_color_free (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3429 while (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3430 FontDetail *font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3431 fonts = g_slist_remove (fonts, font);
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3432 if (font->face)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3433 g_free (font->face);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3434 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3435 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3436 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3437 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3438 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3439 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3440 retval = g_string_append (retval, "</FONT>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3441 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3442 if (retval) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3443 while (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3444 retval = g_string_append (retval, "</B>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3445 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3446 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3447 while (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3448 retval = g_string_append (retval, "</I>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3449 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3450 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3451 while (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3452 retval = g_string_append (retval, "</U>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3453 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3454 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3455 while (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3456 retval = g_string_append (retval, "</S>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3457 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3458 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3459 while (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3460 retval = g_string_append (retval, "</SUB>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3461 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3462 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3463 while (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3464 retval = g_string_append (retval, "</SUP>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3465 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3466 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3467 while (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3468 retval = g_string_append (retval, "</TITLE>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3469 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3470 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3471 while (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3472 retval = g_string_append (retval, "</PRE>");
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3473 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3474 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3475 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3476 g_free (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3477 g_free (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3478
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3479 return retval;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3480 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3481
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3482 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3483 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3484 {
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3485 GtkLayout *layout;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3486
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3487 g_return_if_fail (imhtml != NULL);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3488 g_return_if_fail (GTK_IS_IMHTML (imhtml));
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3489
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3490 layout = GTK_LAYOUT (imhtml);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3491
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3492 while (imhtml->bits) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3493 GtkIMHtmlBit *bit = imhtml->bits->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3494 imhtml->bits = g_list_remove (imhtml->bits, bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3495 if (bit->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3496 g_free (bit->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3497 if (bit->font)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3498 gdk_font_unref (bit->font);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3499 if (bit->fore)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3500 gdk_color_free (bit->fore);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3501 if (bit->back)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3502 gdk_color_free (bit->back);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3503 if (bit->bg)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3504 gdk_color_free (bit->bg);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3505 if (bit->url)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3506 g_free (bit->url);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3507 if (bit->pm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3508 gdk_pixmap_unref (bit->pm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3509 if (bit->bm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3510 gdk_bitmap_unref (bit->bm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3511 while (bit->chunks) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3512 struct line_info *li = bit->chunks->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3513 if (li->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3514 g_free (li->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3515 bit->chunks = g_list_remove (bit->chunks, li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3516 g_free (li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3517 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3518 g_free (bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3519 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3520
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3521 while (imhtml->urls) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3522 g_free (imhtml->urls->data);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3523 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3524 }
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 if (imhtml->selected_text) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3527 g_string_free (imhtml->selected_text, TRUE);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3528 imhtml->selected_text = g_string_new ("");
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3529 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3530
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3531 imhtml->sel_startx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3532 imhtml->sel_starty = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3533 imhtml->sel_endx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3534 imhtml->sel_endx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3535 imhtml->sel_endchunk = NULL;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3536
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3537 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3538 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3539 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3540 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3541 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3542 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3543 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3544 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3545 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3546
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3547 if (imhtml->scroll_timer) {
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3548 gtk_timeout_remove (imhtml->scroll_timer);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3549 imhtml->scroll_timer = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3550 }
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3551
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3552 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
3553
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3554 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3555 imhtml->y = TOP_BORDER;
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3556 imhtml->xsize = 0;
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3557 imhtml->llheight = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3558 imhtml->llascent = 0;
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3559 if (imhtml->line)
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3560 g_list_free (imhtml->line);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3561 imhtml->line = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3562
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3563 layout->hadjustment->page_size = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3564 layout->hadjustment->page_increment = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3565 layout->hadjustment->lower = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3566 layout->hadjustment->upper = imhtml->x;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3567 gtk_adjustment_set_value (layout->hadjustment, 0);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3568
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3569 layout->vadjustment->page_size = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3570 layout->vadjustment->page_increment = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3571 layout->vadjustment->lower = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3572 layout->vadjustment->upper = imhtml->y;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3573 gtk_adjustment_set_value (layout->vadjustment, 0);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3574
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3575 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3576 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3577
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3578 if (GTK_WIDGET_REALIZED (GTK_WIDGET (imhtml)))
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3579 gdk_window_clear (GTK_LAYOUT (imhtml)->bin_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3580 }
2363
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3581
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3582 void
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3583 gtk_imhtml_page_up (GtkIMHtml *imhtml)
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3584 {
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3585 GtkAdjustment *vadj;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3586
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3587 g_return_if_fail (imhtml != NULL);
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3588 g_return_if_fail (GTK_IS_IMHTML (imhtml));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3589
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3590 vadj = GTK_LAYOUT (imhtml)->vadjustment;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3591 gtk_adjustment_set_value (vadj, MAX (vadj->value - vadj->page_increment,
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3592 vadj->lower));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3593 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed");
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3594 }
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3595
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3596 void
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3597 gtk_imhtml_page_down (GtkIMHtml *imhtml)
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3598 {
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3599 GtkAdjustment *vadj;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3600
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3601 g_return_if_fail (imhtml != NULL);
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3602 g_return_if_fail (GTK_IS_IMHTML (imhtml));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3603
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3604 vadj = GTK_LAYOUT (imhtml)->vadjustment;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3605 gtk_adjustment_set_value (vadj, MIN (vadj->value + vadj->page_increment,
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3606 vadj->upper - vadj->page_size));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3607 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed");
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3608 }