annotate src/gtkimhtml.c @ 3052:42be77f603dd

[gaim-migrate @ 3065] MSN pixmaps resized. Forgot to put three of them in the mnu. Thanks, Hette Visser committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Fri, 15 Mar 2002 02:54:08 +0000
parents 200b8133616a
children 55fa49dc545e
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>
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
27 #include <stdlib.h>
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
28 #include <gdk/gdkx.h>
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <gtk/gtk.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <stdio.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <math.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
34 #ifdef HAVE_LANGINFO_CODESET
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
35 #include <langinfo.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
36 #include <locale.h>
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
37 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
39 #if USE_PIXBUF
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
40 #include <gdk-pixbuf/gdk-pixbuf.h>
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
41 #include <gdk-pixbuf/gdk-pixbuf-loader.h>
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
42 #else
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
43 #include "pixmaps/broken.xpm"
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
44 #endif
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
45
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
46 #if GTK_CHECK_VERSION(1,3,0)
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
47 # define GTK_IMHTML_GET_STYLE_FONT(style) gtk_style_get_font (style)
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
48 #else
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
49 # define GTK_IMHTML_GET_STYLE_FONT(style) (style)->font
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
50 # define GTK_CLASS_TYPE(class) (class)->type
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
51 #endif
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
52
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #include "pixmaps/angel.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #include "pixmaps/bigsmile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #include "pixmaps/burp.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #include "pixmaps/crossedlips.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #include "pixmaps/cry.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 #include "pixmaps/embarrassed.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #include "pixmaps/kiss.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 #include "pixmaps/moneymouth.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 #include "pixmaps/sad.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #include "pixmaps/scream.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 #include "pixmaps/smile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 #include "pixmaps/smile8.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 #include "pixmaps/think.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 #include "pixmaps/tongue.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 #include "pixmaps/wink.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 #include "pixmaps/yell.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
2761
367d19133917 [gaim-migrate @ 2774]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2734
diff changeset
70 #define MAX_FONT_SIZE 7
367d19133917 [gaim-migrate @ 2774]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2734
diff changeset
71
2776
3316f391df38 [gaim-migrate @ 2789]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2775
diff changeset
72 #define POINT_SIZE(x) (_point_sizes [MIN ((x), MAX_FONT_SIZE) - 1])
2774
6fab04e257a5 [gaim-migrate @ 2787]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2761
diff changeset
73 static gint _point_sizes [] = { 80, 100, 120, 140, 200, 300, 400 };
2761
367d19133917 [gaim-migrate @ 2774]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2734
diff changeset
74
367d19133917 [gaim-migrate @ 2774]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2734
diff changeset
75 #define DEFAULT_PRE_FACE "courier"
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
77 #define BORDER_SIZE 2
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
78 #define TOP_BORDER 10
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 #define MIN_HEIGHT 20
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 #define HR_HEIGHT 2
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
81 #define TOOLTIP_TIMEOUT 500
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
83 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
84 #define COLOR_MOD 0x8000
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
85 #define COLOR_DIFF 0x800
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
86
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 #define TYPE_TEXT 0
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 #define TYPE_SMILEY 1
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 #define TYPE_IMG 2
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 #define TYPE_SEP 3
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 #define TYPE_BR 4
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 #define TYPE_COMMENT 5
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
94 #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
95
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 typedef struct _GtkIMHtmlBit GtkIMHtmlBit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 typedef struct _FontDetail FontDetail;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
99 struct _GtkSmileyTree {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
100 GString *values;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
101 GtkSmileyTree **children;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
102 gchar **image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
103 };
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
104
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
105 static GtkSmileyTree*
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
106 gtk_smiley_tree_new ()
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 return g_new0 (GtkSmileyTree, 1);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
109 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
110
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
111 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
112 gtk_smiley_tree_insert (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
113 const gchar *text,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
114 gchar **image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
115 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
116 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
117 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
118
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
119 if (!strlen (x))
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
120 return;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
121
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
122 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
123 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
124 gint index;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
125
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
126 if (!t->values)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
127 t->values = g_string_new ("");
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 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
130 if (!pos) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
131 t->values = g_string_append_c (t->values, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
132 index = t->values->len - 1;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
133 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *));
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
134 t->children [index] = g_new0 (GtkSmileyTree, 1);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
135 } else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
136 index = (int) pos - (int) t->values->str;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
137
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
138 t = t->children [index];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
139
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
140 x++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
141 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
142
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
143 t->image = image;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
144 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
145
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
146 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
147 gtk_smiley_tree_remove (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
148 const gchar *text)
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 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
151 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
152 gint len = 0;
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 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
155 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
156
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
157 if (!t->values)
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 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
161 if (pos)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
162 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
163 else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
164 return;
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 x++; len++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
167 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
168
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
169 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
170 t->image = NULL;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
171 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
172
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
173 static gint
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
174 gtk_smiley_tree_lookup (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
175 const gchar *text)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
176 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
177 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
178 const gchar *x = text;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
179 gint len = 0;
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 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
182 gchar *pos;
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 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
185 return len;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
186
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
187 if (!t->values)
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 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
191 if (pos)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
192 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
193 else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
194 return 0;
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 x++; len++;
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 if (t->image)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
200 return len;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
201
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
202 return 0;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
203 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
204
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
205 static gchar**
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
206 gtk_smiley_tree_image (GtkSmileyTree *tree,
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
207 const gchar *text)
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 GtkSmileyTree *t = tree;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
210 const gchar *x = text;
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 while (*x) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
213 gchar *pos;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
214
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
215 if (!t->values)
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 pos = strchr (t->values->str, *x);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
219 if (pos) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
220 t = t->children [(int) pos - (int) t->values->str];
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
221 } else
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
222 return NULL;
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 x++;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
225 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
226
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
227 return t->image;
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
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
230 static void
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
231 gtk_smiley_tree_destroy (GtkSmileyTree *tree)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
232 {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
233 GSList *list = g_slist_append (NULL, tree);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
234
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
235 while (list) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
236 GtkSmileyTree *t = list->data;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
237 gint i;
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
238 list = g_slist_remove(list, t);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
239 if (t->values) {
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
240 for (i = 0; i < t->values->len; i++)
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
241 list = g_slist_append (list, t->children [i]);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
242 g_string_free (t->values, TRUE);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
243 g_free (t->children);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
244 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
245 g_free (t);
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
246 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
247 }
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
248
2728
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
249 void
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
250 gtk_imhtml_remove_smileys (GtkIMHtml *imhtml)
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
251 {
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
252 g_return_if_fail (imhtml != NULL);
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
253 g_return_if_fail (GTK_IS_IMHTML (imhtml));
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
254
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
255 gtk_smiley_tree_destroy (imhtml->smiley_data);
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
256 imhtml->smiley_data = gtk_smiley_tree_new ();
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
257 }
16df889d81e2 [gaim-migrate @ 2741]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2714
diff changeset
258
3050
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
259 void
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
260 gtk_imhtml_reset_smileys (GtkIMHtml *imhtml)
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
261 {
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
262 gtk_imhtml_remove_smileys(imhtml);
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
263 gtk_imhtml_init_smileys (imhtml);
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
264 }
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
265
200b8133616a [gaim-migrate @ 3063]
Rob Flynn <gaim@robflynn.com>
parents: 3010
diff changeset
266
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
267 struct im_image {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
268 gchar *filename;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
269
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
270 gint len;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
271 gpointer data;
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
272
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
273 gint x,y;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
274 gint width,height;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
275 GtkIMHtml *imhtml;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
276 GtkIMHtmlBit *bit;
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
277 #if USE_PIXBUF
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
278 GdkPixbuf *pb;
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
279 #endif
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
280 };
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
281
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 struct _GtkIMHtmlBit {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 gint type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 gchar *text;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
286 struct im_image *img;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 GdkPixmap *pm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 GdkBitmap *bm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 GdkColor *bg;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 gboolean underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 gboolean strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 gchar *url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 GList *chunks;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 struct _FontDetail {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 gushort size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 gchar *face;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 struct line_info {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 gint height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 gint ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 gboolean selected;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 gchar *sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 gchar *sel_end;
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 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
323 struct clickable {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 gint height;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
328 GtkIMHtml *imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
329 GtkIMHtmlBit *bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 static GtkLayoutClass *parent_class = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 TARGET_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 TARGET_TEXT,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 TARGET_COMPOUND_TEXT
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 LAST_SIGNAL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 static void gtk_imhtml_draw_bit (GtkIMHtml *, GtkIMHtmlBit *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 static GdkColor *gtk_imhtml_get_color (const gchar *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 static gint gtk_imhtml_motion_notify_event (GtkWidget *, GdkEventMotion *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 static void
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
351 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
352 gtk_imhtml_finalize (GObject *object)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
353 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 gtk_imhtml_destroy (GtkObject *object)
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
355 #endif
1428
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 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 imhtml = GTK_IMHTML (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
361 gtk_imhtml_clear (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 if (imhtml->selected_text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
366 if (imhtml->default_font)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
367 gdk_font_unref (imhtml->default_font);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
368 if (imhtml->default_fg_color)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
369 gdk_color_free (imhtml->default_fg_color);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
370 if (imhtml->default_bg_color)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
371 gdk_color_free (imhtml->default_bg_color);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
372 if (imhtml->default_hl_color)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
373 gdk_color_free (imhtml->default_hl_color);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
374 if (imhtml->default_hlfg_color)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
375 gdk_color_free (imhtml->default_hlfg_color);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
376
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 gdk_cursor_destroy (imhtml->hand_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 gdk_cursor_destroy (imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
380 gtk_smiley_tree_destroy (imhtml->smiley_data);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
382 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
383 G_OBJECT_CLASS (parent_class)->finalize (object);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
384 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
387 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 }
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 gtk_imhtml_realize (GtkWidget *widget)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 GtkIMHtml *imhtml;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
394 GdkWindowAttr attributes;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
395 gint attributes_mask;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 imhtml = GTK_IMHTML (widget);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
401 GTK_WIDGET_SET_FLAGS (imhtml, GTK_REALIZED);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
402
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
403 attributes.window_type = GDK_WINDOW_CHILD;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
404 attributes.x = widget->allocation.x;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
405 attributes.y = widget->allocation.y;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
406 attributes.width = widget->allocation.width;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
407 attributes.height = widget->allocation.height;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
408 attributes.wclass = GDK_INPUT_OUTPUT;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
409 attributes.visual = gtk_widget_get_visual (widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
410 attributes.colormap = gtk_widget_get_colormap (widget);
2556
e284ab2882bd [gaim-migrate @ 2569]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
411 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
412
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
413 attributes_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
414
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
415 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
416 &attributes, attributes_mask);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
417 gdk_window_set_user_data (widget->window, widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
418
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
419 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
420 attributes.x = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
421 attributes.y = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
422 #else
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
423 attributes.x = widget->style->klass->xthickness + BORDER_SIZE;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
424 attributes.y = widget->style->klass->xthickness + BORDER_SIZE;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
425 #endif
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
426 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
427 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
428 attributes.event_mask = gtk_widget_get_events (widget)
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
429 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
430 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
431
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
432 GTK_LAYOUT (imhtml)->bin_window = gdk_window_new (widget->window,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
433 &attributes, attributes_mask);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
434 gdk_window_set_user_data (GTK_LAYOUT (imhtml)->bin_window, widget);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 widget->style = gtk_style_attach (widget->style, widget->window);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
440 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
441
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
442 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
443 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
444 &widget->style->base [GTK_STATE_NORMAL]);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
445
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
446 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
447 imhtml->default_bg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
448 imhtml->default_hl_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->bg [GTK_STATE_SELECTED]);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
449 imhtml->default_hlfg_color=gdk_color_copy (&GTK_WIDGET (imhtml)->style->fg [GTK_STATE_SELECTED]);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2365
diff changeset
450
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
451 gdk_window_show (GTK_LAYOUT (imhtml)->bin_window);
1460
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
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
454 static gboolean
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
455 similar_colors (GdkColor *bg,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
456 GdkColor *fg)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
457 {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
458 if ((DIFF (bg->red, fg->red) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
459 (DIFF (bg->green, fg->green) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
460 (DIFF (bg->blue, fg->blue) < COLOR_DIFF)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
461 fg->red = (0xff00 - COLOR_MOD > bg->red) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
462 bg->red + COLOR_MOD : bg->red - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
463 fg->green = (0xff00 - COLOR_MOD > bg->green) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
464 bg->green + COLOR_MOD : bg->green - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
465 fg->blue = (0xff00 - COLOR_MOD > bg->blue) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
466 bg->blue + COLOR_MOD : bg->blue - COLOR_MOD;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
467 return TRUE;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
468 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
469 return FALSE;
1428
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
473 draw_text (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
474 struct line_info *line)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
476 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
477 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
478 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
479 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
480 gfloat xoff, yoff;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
481 GdkColor *bg, *fg;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
482 gchar *start = NULL, *end = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
483
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
484 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
485 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
486
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
487 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
488 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
489 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
490 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
491 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
492
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
493 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
494 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
495 gdk_gc_set_foreground (gc, bit->bg);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
496 bg = bit->bg;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
497 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
498 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
499 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
500 bg = imhtml->default_bg_color;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
501 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
502
2338
2bf8a8131479 [gaim-migrate @ 2351]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2337
diff changeset
503 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
504 line->width ? line->width : imhtml->xsize, line->height);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
505
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
506 if (!line->text) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
507 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
508 return;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
509 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
510
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
511 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
512 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
513 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
514 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
515 gdk_string_width (bit->font, line->text), line->height);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
516 bg = bit->back;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
517 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
518
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
519 bg = gdk_color_copy (bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
520
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
521 if (line->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
522 gint width, x;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
523
1447
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)
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
538 end = strchr(line->text, '\0');
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
539
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
540 width = gdk_text_width (bit->font, line->text, end - line->text) - x;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
541
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
542 gdk_gc_set_foreground (gc, imhtml->default_hl_color);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
543
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
544 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
545 width, line->height);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
546 gdk_gc_set_foreground (gc, imhtml->default_hlfg_color);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
547 fg = gdk_color_copy(imhtml->default_hlfg_color);
1447
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 if (bit->url) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
550 GdkColor *tc = gtk_imhtml_get_color ("#0000a0");
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
551 gdk_color_alloc (cmap, tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
552 gdk_gc_set_foreground (gc, tc);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
553 fg = gdk_color_copy (tc);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
554 gdk_color_free (tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
555 } else if (bit->fore) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
556 gdk_color_alloc (cmap, bit->fore);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
557 gdk_gc_set_foreground (gc, bit->fore);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
558 fg = gdk_color_copy (bit->fore);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
559 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
560 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
561 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
562 fg = gdk_color_copy (imhtml->default_fg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
563 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
564
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
565 if (similar_colors (bg, fg)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
566 gdk_color_alloc (cmap, fg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
567 gdk_gc_set_foreground (gc, fg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
568 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
569
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
570 if (start) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
571 int offset = 0;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
572 gdk_draw_text (window, bit->font, gc, line->x - xoff,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
573 line->y - yoff + line->ascent, line->text, start - line->text);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
574 offset = gdk_text_width(bit->font, line->text, start - line->text);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
575 if (bit->underline || bit->url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
576 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
577 line->y - yoff + line->ascent + 1,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
578 offset, 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
579 if (bit->strike)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
580 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
581 line->y - yoff + line->ascent - (bit->font->ascent / 2),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
582 offset, 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
583 gdk_gc_set_foreground (gc, imhtml->default_hlfg_color);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
584 gdk_draw_text (window, bit->font, gc, line->x - xoff + offset,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
585 line->y - yoff + line->ascent, start, end - start);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
586 if (bit->underline || bit->url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
587 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff + offset,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
588 line->y - yoff + line->ascent + 1,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
589 gdk_text_width(bit->font, line->text, end - start), 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
590 if (bit->strike)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
591 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff + offset,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
592 line->y - yoff + line->ascent - (bit->font->ascent / 2),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
593 gdk_text_width(bit->font, line->text, end - start), 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
594 offset = gdk_text_width(bit->font, line->text, end - line->text);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
595 gdk_gc_set_foreground (gc, fg);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
596 gdk_draw_string (window, bit->font, gc, line->x - xoff + offset,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
597 line->y - yoff + line->ascent, end);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
598 if (bit->underline || bit->url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
599 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff + offset,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
600 line->y - yoff + line->ascent + 1,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
601 gdk_string_width(bit->font, end), 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
602 if (bit->strike)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
603 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff + offset,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
604 line->y - yoff + line->ascent - (bit->font->ascent / 2),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
605 gdk_string_width(bit->font, end), 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
606 } else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
607 gdk_draw_string (window, bit->font, gc, line->x - xoff,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
608 line->y - yoff + line->ascent, line->text);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
609
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
610 if (bit->underline || bit->url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
611 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff + line->ascent + 1,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
612 gdk_string_width (bit->font, line->text), 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
613 if (bit->strike)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
614 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
615 line->y - yoff + line->ascent - (bit->font->ascent / 2),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
616 gdk_string_width (bit->font, line->text), 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
617 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
618
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
619 gdk_color_free (bg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
620 gdk_color_free (fg);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
621
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
622
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
623
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
624 gdk_gc_unref (gc);
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
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
627 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
628 draw_img (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
629 struct line_info *line)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
630 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
631 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
632 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
633 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
634 gint width, height, hoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
635 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
636 gfloat xoff, yoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
637
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
638 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
639 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
640
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
641 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
642 gdk_window_get_size (bit->pm, &width, &height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
643 hoff = (line->height - height) / 2;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
644 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
645 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
646 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
647 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
648
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
649 if (bit->bg != NULL) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
650 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
651 gdk_gc_set_foreground (gc, bit->bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
652 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
653 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
654 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
655 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
656
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
657 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
658
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
659 if (line->selected) {
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
660 gdk_color_alloc (cmap, imhtml->default_hl_color);
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
661 gdk_gc_set_foreground(gc, imhtml->default_hl_color);
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
662 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff,
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
663 width, line->height);
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
664 } else if (bit->back != NULL) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
665 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
666 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
667 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
668
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
669 if (bit->bm) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
670 gdk_gc_set_clip_mask(gc, bit->bm);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
671 gdk_gc_set_clip_origin(gc, line->x - xoff, line->y - yoff + hoff);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
672 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
673 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
674
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
675 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
676 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
677
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
678 static void
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
679 draw_line (GtkIMHtml *imhtml,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
680 struct line_info *line)
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
681 {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
682 GtkIMHtmlBit *bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
683 GdkDrawable *drawable;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
684 GdkColormap *cmap;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
685 GdkGC *gc;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
686 guint line_height;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
687 gfloat xoff, yoff;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
688
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
689 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
690 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
691
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
692 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
693 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
694 bit = line->bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
695 drawable = GTK_LAYOUT (imhtml)->bin_window;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
696 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
697 gc = gdk_gc_new (drawable);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
698
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
699 if (line->selected) {
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
700 gdk_color_alloc (cmap, imhtml->default_hl_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
701 gdk_gc_set_foreground (gc, imhtml->default_hl_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
702 } else if (bit->bg != NULL) {
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
703 gdk_color_alloc (cmap, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
704 gdk_gc_set_foreground (gc, bit->bg);
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
705 } else {
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
706 gdk_color_alloc (cmap, imhtml->default_bg_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
707 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
708 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
709
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
710 gdk_draw_rectangle (drawable, gc, TRUE, line->x - xoff, line->y - yoff,
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
711 line->width, line->height);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
712
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
713
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
714 if (line->selected) {
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
715 gdk_color_alloc (cmap, imhtml->default_hlfg_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
716 gdk_gc_set_foreground (gc, imhtml->default_hlfg_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
717 } else {
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
718 gdk_color_alloc (cmap, imhtml->default_fg_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
719 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2994
diff changeset
720 }
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
721
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
722 line_height = line->height / 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
723
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
724 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
725 line->width, line_height);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
726
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
727 gdk_gc_unref (gc);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
728 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
729
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
730 static void
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
731 gtk_imhtml_draw_focus (GtkWidget *widget)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
732 {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
733 GtkIMHtml *imhtml;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
734 gint x = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
735 y = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
736 w = 0,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
737 h = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
738
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
739 imhtml = GTK_IMHTML (widget);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
740
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
741 if (!GTK_WIDGET_DRAWABLE (widget))
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
742 return;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
743
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
744 if (GTK_WIDGET_HAS_FOCUS (widget)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
745 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
746 widget->allocation.width - 1, widget->allocation.height - 1);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
747 x = 1; y = 1; w = 2; h = 2;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
748 }
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
749
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
750 gtk_paint_shadow (widget->style, widget->window, GTK_STATE_NORMAL,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
751 GTK_SHADOW_IN, NULL, widget, "text", x, y,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
752 widget->allocation.width - w, widget->allocation.height - h);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
753 }
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
754
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
755 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
756 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
757 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
758 GList *bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
759 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
760 GList *chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
761 struct line_info *line;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
762 gfloat x, y;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
763 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
764 guint32 width, height;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
765 #else
2048
3366311426df [gaim-migrate @ 2058]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2022
diff changeset
766 gint width, height;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
767 #endif
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
768
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
769 x = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
770 y = GTK_LAYOUT (imhtml)->vadjustment->value;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
771 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
772
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
773 bits = imhtml->bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
774
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
775 while (bits) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
776 bit = bits->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
777 chunks = bit->chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
778 if (DRAW_IMG (bit)) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
779 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
780 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
781 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
782 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
783 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
784 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
785 draw_img (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
786 }
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
787 } else if (bit->type == TYPE_SEP) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
788 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
789 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
790 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
791 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
792 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
793 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
794 draw_line (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
795
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
796 line = chunks->next->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
797 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
798 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
799 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
800 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
801 draw_text (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
802 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
803 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
804 while (chunks) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
805 line = chunks->data;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
806 if ((line->x <= x + width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
807 (line->y <= y + height) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
808 (x <= line->x + line->width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
809 (y <= line->y + line->height))
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
810 draw_text (imhtml, line);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
811 chunks = g_list_next (chunks);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
812 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
813 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
814 bits = g_list_next (bits);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
815 }
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
816
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
817 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
820 #if !GTK_CHECK_VERSION(1,3,0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 gtk_imhtml_draw (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 GdkRectangle *area)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
825 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
826
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
827 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
828 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 }
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
830 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 gtk_imhtml_style_set (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 GtkStyle *style)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 g_return_if_fail (GTK_IS_IMHTML (widget));
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
840
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
841 if (GTK_WIDGET_CLASS (parent_class)->style_set)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
842 (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, style);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
843
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 if (!GTK_WIDGET_REALIZED (widget))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 imhtml = GTK_IMHTML (widget);
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
848 if (imhtml->default_fg_color)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
849 gdk_color_free(imhtml->default_fg_color);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
850 if (imhtml->default_bg_color)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
851 gdk_color_free(imhtml->default_bg_color);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
852 if (imhtml->default_hl_color)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
853 gdk_color_free(imhtml->default_hl_color);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
854 if (imhtml->default_hlfg_color)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
855 gdk_color_free(imhtml->default_hlfg_color);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
856 imhtml->default_fg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
857 imhtml->default_bg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
858 imhtml->default_hl_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->bg [GTK_STATE_SELECTED]);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
859 imhtml->default_hlfg_color=gdk_color_copy (&GTK_WIDGET (imhtml)->style->fg [GTK_STATE_SELECTED]);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
860 if (imhtml->default_font)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
861 gdk_font_unref (imhtml->default_font);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
862 imhtml->default_font = gdk_font_ref (GTK_IMHTML_GET_STYLE_FONT (widget->style));
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
863 gdk_window_set_background (widget->window, &widget->style->base [GTK_STATE_NORMAL]);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
864 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window,
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
865 &widget->style->base [GTK_STATE_NORMAL]);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
866 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
868
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869 static gint
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
870 gtk_imhtml_expose_event (GtkWidget *widget,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
871 GdkEventExpose *event)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
873 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
874
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
875 g_return_val_if_fail (widget != NULL, FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
876 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
877
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
878 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
879 gtk_imhtml_draw_exposed (imhtml);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
880
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
881 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 gtk_imhtml_redraw_all (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 GList *b;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 gfloat oldvalue;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
891 gint oldy;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 oldvalue = vadj->value / vadj->upper;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
895 oldy = imhtml->y;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
897 gtk_layout_freeze (GTK_LAYOUT (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
902 while (imhtml->click) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
903 g_free (imhtml->click->data);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
904 imhtml->click = g_list_remove (imhtml->click, imhtml->click->data);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
907 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
908 imhtml->y = TOP_BORDER;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911
2809
c479d54abc0a [gaim-migrate @ 2822]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2779
diff changeset
912 if (GTK_LAYOUT (imhtml)->vadjustment->value < TOP_BORDER)
2002
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
913 gdk_window_clear_area (GTK_LAYOUT (imhtml)->bin_window, 0, 0,
2809
c479d54abc0a [gaim-migrate @ 2822]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2779
diff changeset
914 imhtml->xsize,
c479d54abc0a [gaim-migrate @ 2822]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2779
diff changeset
915 TOP_BORDER - GTK_LAYOUT (imhtml)->vadjustment->value);
2002
7c2457745344 [gaim-migrate @ 2012]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1998
diff changeset
916
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
917 b = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
918 while (b) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
919 bit = b->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
920 b = g_list_next (b);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
921 while (bit->chunks) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
922 struct line_info *li = bit->chunks->data;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
923 if (li->text)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
924 g_free (li->text);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
925 bit->chunks = g_list_remove (bit->chunks, li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
926 g_free (li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
927 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
928 gtk_imhtml_draw_bit (imhtml, bit);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
931 GTK_LAYOUT (imhtml)->height = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
932 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
933 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
934
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
935 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 gtk_adjustment_set_value (vadj, vadj->upper * oldvalue);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
937
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
938 if (GTK_LAYOUT (imhtml)->bin_window && (imhtml->y < oldy)) {
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
939 GdkGC *gc;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
940 GdkColormap *cmap;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
941
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
942 gc = gdk_gc_new (GTK_LAYOUT (imhtml)->bin_window);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
943 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
944
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
945 gdk_color_alloc (cmap, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
946 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
947
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
948 gdk_draw_rectangle (GTK_LAYOUT (imhtml)->bin_window, gc, TRUE,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
949 0, imhtml->y - GTK_LAYOUT (imhtml)->vadjustment->value,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
950 GTK_WIDGET (imhtml)->allocation.width,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
951 oldy - imhtml->y);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
952
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
953 gdk_gc_unref (gc);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
954 }
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
955
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
956 gtk_layout_thaw (GTK_LAYOUT (imhtml));
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
957 gtk_imhtml_draw_focus (GTK_WIDGET (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
958 }
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 gtk_imhtml_size_allocate (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 GtkAllocation *allocation)
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 GtkIMHtml *imhtml;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
965 GtkLayout *layout;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
966 gint new_xsize, new_ysize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 g_return_if_fail (allocation != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 imhtml = GTK_IMHTML (widget);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
973 layout = GTK_LAYOUT (widget);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
974
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
975 widget->allocation = *allocation;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
976
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
977 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
978 new_xsize = MAX (1, (gint) allocation->width -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
979 (gint) (widget->style->xthickness + BORDER_SIZE) * 2);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
980 new_ysize = MAX (1, (gint) allocation->height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
981 (gint) (widget->style->ythickness + BORDER_SIZE) * 2);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
982
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
983 if (GTK_WIDGET_REALIZED (widget)) {
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
984 gint x = widget->style->xthickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
985 gint y = widget->style->ythickness + BORDER_SIZE;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
986 gdk_window_move_resize (widget->window,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
987 allocation->x, allocation->y,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
988 allocation->width, allocation->height);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
989 gdk_window_move_resize (layout->bin_window,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
990 x, y, new_xsize, new_ysize);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
991 }
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
992 #else
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
993 new_xsize = MAX (1, (gint) allocation->width -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
994 (gint) (widget->style->klass->xthickness + BORDER_SIZE) * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
995 new_ysize = MAX (1, (gint) allocation->height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
996 (gint) (widget->style->klass->ythickness + BORDER_SIZE) * 2);
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
997
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
998 if (GTK_WIDGET_REALIZED (widget)) {
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
999 gint x = widget->style->klass->xthickness + BORDER_SIZE;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1000 gint y = widget->style->klass->ythickness + BORDER_SIZE;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1001 gdk_window_move_resize (widget->window,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1002 allocation->x, allocation->y,
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1003 allocation->width, allocation->height);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1004 gdk_window_move_resize (layout->bin_window,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1005 x, y, new_xsize, new_ysize);
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1006 }
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1007 #endif
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1008
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1009 layout->hadjustment->page_size = new_xsize;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1010 layout->hadjustment->page_increment = new_xsize / 2;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1011 layout->hadjustment->lower = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1012 layout->hadjustment->upper = imhtml->x;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1013
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1014 layout->vadjustment->page_size = new_ysize;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1015 layout->vadjustment->page_increment = new_ysize / 2;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1016 layout->vadjustment->lower = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1017 layout->vadjustment->upper = imhtml->y;
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1018
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1019 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1020 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1022 if (new_xsize == imhtml->xsize) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1023 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y - new_ysize)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1024 if (imhtml->y > new_ysize)
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1025 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment,
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1026 imhtml->y - new_ysize);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1027 else
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1028 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, 0);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1029 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 return;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1031 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1033 imhtml->xsize = new_xsize;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1035 if (GTK_WIDGET_REALIZED (widget))
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1036 gtk_imhtml_redraw_all (imhtml);
1428
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 gtk_imhtml_select_none (GtkIMHtml *imhtml)
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 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045 struct line_info *chunk;
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 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1055 chunk = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1056
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1057 if (chunk->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1058 chunk->selected = FALSE;
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1059 chunk->sel_start = chunk->text;
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1060 chunk->sel_end = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1061 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1062 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1063 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1064 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1065 else if (chunk->width)
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1066 draw_text (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1067 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1073 }
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1074 imhtml->sel_endchunk = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1076
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1077 static gchar*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078 get_position (struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 gint x,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 gint width = x - chunk->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 gchar *pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 guint total = 0;
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 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 if (smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1100 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1101 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 if (width <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104 return text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106 for (pos = text; *pos != '\0'; pos++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 gint char_width = gdk_text_width (chunk->bit->font, pos, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 if ((width > total) && (width <= total + char_width)) {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1109 if (width < total + (char_width / 2))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 return ++pos;
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 total += char_width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 }
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 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 static GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 append_to_sel (GString *string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1125 GString *new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126 gchar *buf;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 gchar *start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 gint length;
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 (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1133 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1138 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1140 if (smileys) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 start = (chunk->sel_start == NULL) ? chunk->bit->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1142 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1143 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 case TYPE_BR:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 buf = g_strdup ("\n");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 new_string = g_string_append (string, buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 g_free (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 return new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1168 static void
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1169 chunk_select_words (struct line_info *chunk)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1170 {
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1171 char *start, *end;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1172
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1173 start = chunk->sel_start;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1174 end = chunk->sel_end;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1175
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1176 if (start != chunk->text)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1177 while (start > chunk->text && *(start-1) != ' ')
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1178 start--;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1179 chunk->sel_start = start;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1180
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1181 if (end != NULL)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1182 while (*end != '\0' && *end != ' ')
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1183 end++;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1184 chunk->sel_end = end;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1185 }
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1186
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 #define COORDS_IN_CHUNK(xx, yy) (((xx) < chunk->x + chunk->width) && \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 ((yy) < chunk->y + chunk->height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 gtk_imhtml_select_bits (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 guint startx = imhtml->sel_startx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199 starty = imhtml->sel_starty,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 endx = imhtml->sel_endx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 endy = imhtml->sel_endy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202 gchar *new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 gint selection = 0;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1204 guint mode = imhtml->sel_mode;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 gboolean smileys = imhtml->smileys;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 gboolean redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 gboolean got_start = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 gboolean got_end = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 if (!imhtml->selection)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 if (imhtml->selected_text) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1220 if (mode == 2)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1221 startx = endx = 0;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1222
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 chunks = bit->chunks;
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 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1229 chunk = chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 switch (selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 case 0:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 if (COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 new_pos = get_position (chunk, startx, smileys);
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1235 if (!chunk->selected ||
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 got_start = TRUE;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1244 if (mode == 2)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1245 endy += chunk->height;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1246 if (mode == 1)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1247 chunk_select_words (chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1248 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1250 if (COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251 if (got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1252 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 if (chunk->sel_end != new_pos)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 if (chunk->sel_start > new_pos) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 chunk->sel_end = chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260 selection = 2;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1261 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262 got_end = TRUE;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1263 if (mode == 1)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1264 chunk_select_words (chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1268 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1275 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 got_end = TRUE;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1277 if (mode == 2)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1278 starty += chunk->height;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1279 if (mode == 1)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1280 chunk_select_words (chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282 } else if (!COORDS_IN_CHUNK (startx, starty) && !got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 if (chunk->selected)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1285 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1289
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 if (!got_start && COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302 got_start = TRUE;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1303 if (mode == 1)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1304 chunk_select_words (chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305 } else if (!got_end && COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1307 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1315 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1316 got_end = TRUE;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1317 if (mode == 1)
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1318 chunk_select_words (chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 if ( !chunk->selected ||
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1321 (chunk->sel_end != NULL) ||
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1322 (chunk->sel_start != chunk->text))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1327 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1328
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1329 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1330 case 2:
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1331 if (chunk->selected)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1332 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1333 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1334 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1335 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1336 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1337 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1338
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339 if (chunk->selected == TRUE)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 imhtml->selected_text = append_to_sel (imhtml->selected_text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341 chunk, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1343 if (redraw) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1344 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1345 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1346 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1347 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1348 else if (chunk->width)
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1349 draw_text (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1350 redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1355
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1356 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1357 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1359
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1360 static void
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1361 gtk_imhtml_select_in_chunk (GtkIMHtml *imhtml,
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1362 struct line_info *chunk)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1363 {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1364 GtkIMHtmlBit *bit = chunk->bit;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1365 gchar *new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1366 guint endx = imhtml->sel_endx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1367 guint startx = imhtml->sel_startx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1368 guint starty = imhtml->sel_starty;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1369 gboolean smileys = imhtml->smileys;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1370 gboolean redraw = FALSE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1371
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1372 new_pos = get_position (chunk, endx, smileys);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1373 if ((starty < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1374 ((starty < chunk->y + chunk->height) && (startx < endx))) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1375 if (chunk->sel_end != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1376 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1377 chunk->sel_end = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1378 } else {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1379 if (chunk->sel_start != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1380 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1381 chunk->sel_start = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1382 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1383
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1384 if (redraw) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1385 if (DRAW_IMG (bit))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1386 draw_img (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1387 else if ((bit->type == TYPE_SEP) &&
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1388 (bit->chunks->data == chunk))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1389 draw_line (imhtml, chunk);
2348
dd5f18429dd9 [gaim-migrate @ 2361]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2338
diff changeset
1390 else if (chunk->width)
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1391 draw_text (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1392 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1393 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1394
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1395 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1396 scroll_timeout (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1397 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398 GdkEventMotion event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400 GdkModifierType mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1404 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
1405
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 if (mask & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407 event.is_hint = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408 event.x = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409 event.y = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 event.state = mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 gtk_imhtml_motion_notify_event (GTK_WIDGET (imhtml), &event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 return FALSE;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 static gint
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1419 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1420 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1421 GtkStyle *style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1422 GdkFont *font;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1423 gint y, baseline_skip, gap;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1424
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1425 style = imhtml->tip_window->style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1426 font = GTK_IMHTML_GET_STYLE_FONT (style);
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1427
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1428 gap = (font->ascent + font->descent) / 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1429 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1430 gap = 2;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1431 baseline_skip = font->ascent + font->descent + gap;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1432
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1433 if (!imhtml->tip_bit)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1434 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1435
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1436 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
1437 NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1438
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1439 y = font->ascent + 4;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1440 if (imhtml->tip_bit->url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1441 gtk_paint_string (style, imhtml->tip_window->window, GTK_STATE_NORMAL, NULL,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1442 imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->url);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1443 else if (imhtml->tip_bit->img)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1444 gtk_paint_string (style, imhtml->tip_window->window, GTK_STATE_NORMAL, NULL,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1445 imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->img->filename);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1446
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1447 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1448 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1449
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1450 static gint
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1451 gtk_imhtml_tip (gpointer data)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1452 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1453 GtkIMHtml *imhtml = data;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1454 GtkWidget *widget = GTK_WIDGET (imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1455 GtkStyle *style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1456 GdkFont *font;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1457 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
1458
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1459 if (!imhtml->tip_bit || !GTK_WIDGET_DRAWABLE (widget)) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1460 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1461 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1462 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1463
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1464 if (imhtml->tip_window)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1465 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1466
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1467 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1468 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1469 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
1470 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips");
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1471 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "expose_event",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1472 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1473 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "draw",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1474 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1475
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1476 gtk_widget_ensure_style (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1477 style = imhtml->tip_window->style;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1478 font = GTK_IMHTML_GET_STYLE_FONT (style);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1479
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1480 scr_w = gdk_screen_width ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1481 scr_h = gdk_screen_height ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1482
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1483 gap = (font->ascent + font->descent) / 4;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1484 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1485 gap = 2;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1486 baseline_skip = font->ascent + font->descent + gap;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1487
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1488 w = 8 + gdk_string_width (font, imhtml->tip_bit->img ? imhtml->tip_bit->img->filename :
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1489 imhtml->tip_bit->url);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1490 h = 8 - gap + baseline_skip;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1491
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1492 gdk_window_get_pointer (NULL, &x, &y, NULL);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1493 if (GTK_WIDGET_NO_WINDOW (widget))
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1494 y += widget->allocation.y;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1495
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1496 x -= ((w >> 1) + 4);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1497
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1498 if ((x + w) > scr_w)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1499 x -= (x + w) - scr_w;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1500 else if (x < 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1501 x = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1502
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1503 if ((y + h + + 4) > scr_h)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1504 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
1505 else
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1506 if (imhtml->tip_bit->font)
0fd338304759 [gaim-migrate @ 2081]
Rob Flynn <gaim@robflynn.com>
parents: 2065
diff changeset
1507 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
1508 else
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1509 y = y + font->ascent + font->descent;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1510
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1511 gtk_widget_set_usize (imhtml->tip_window, w, h);
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1512 gtk_widget_set_uposition (imhtml->tip_window, x, y);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1513 gtk_widget_show (imhtml->tip_window);
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1514
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1515 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1516 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1517 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1518
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1519 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1520 gtk_imhtml_motion_notify_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1521 GdkEventMotion *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1522 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1523 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1524 GdkModifierType state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1527 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529 if (event->is_hint)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1530 gdk_window_get_pointer (event->window, &x, &y, &state);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1531 else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1534 state = event->state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1535 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537 if (state & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1538 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1539 gint height = vadj->page_size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540 gint yy = y - vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542 if (((yy < 0) || (yy > height)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543 (imhtml->scroll_timer == 0) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544 (vadj->upper > vadj->page_size)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 imhtml->scroll_timer = gtk_timeout_add (100,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 (GtkFunction) scroll_timeout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 imhtml);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1548 diff = (yy < 0) ? (yy / 2) : ((yy - height) / 2);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 gtk_adjustment_set_value (vadj,
2337
e3939d21c2f0 [gaim-migrate @ 2350]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2188
diff changeset
1550 MIN (vadj->value + diff, vadj->upper - height));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 }
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 if (imhtml->selection) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1554 struct line_info *chunk = imhtml->sel_endchunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1556 imhtml->sel_endy = MAX (y, 0);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1557 if ((chunk == NULL) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1558 (x < chunk->x) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1559 (x > chunk->x + chunk->width) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1560 (y < chunk->y) ||
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1561 (y > chunk->y + chunk->height) ||
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1562 (imhtml->sel_mode > 0))
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1563 gtk_imhtml_select_bits (imhtml);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1564 else
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1565 gtk_imhtml_select_in_chunk (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1566 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1567 } else {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1568 GList *click = imhtml->click;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1569 struct clickable *uw;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1570
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1571 while (click) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1572 uw = (struct clickable *) click->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573 if ((x > uw->x) && (x < uw->x + uw->width) &&
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1574 (y > uw->y) && (y < uw->y + uw->height) &&
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1575 (uw->bit->url || uw->bit->img)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1576 if (imhtml->tip_bit != uw->bit) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1577 imhtml->tip_bit = uw->bit;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1578 if (imhtml->tip_timer != 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1579 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1580 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1581 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1582 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1583 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1584 imhtml->tip_timer = gtk_timeout_add (TOOLTIP_TIMEOUT,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1585 gtk_imhtml_tip,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1586 imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1587 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1588 if (uw->bit->url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1589 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1590 imhtml->hand_cursor);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1591 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1592 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1593 click = g_list_next (click);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1594 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1595 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1597 if (imhtml->tip_timer) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1598 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1599 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1600 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1601 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1602 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1603 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1604 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1605 imhtml->tip_bit = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1606
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1607 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
1608
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1609 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1610 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1611
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1612 static gint
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1613 gtk_imhtml_leave_notify_event (GtkWidget *widget,
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1614 GdkEventCrossing *event)
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1615 {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1616 GtkIMHtml *imhtml = GTK_IMHTML (widget);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1617
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1618 if (imhtml->tip_timer) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1619 gtk_timeout_remove (imhtml->tip_timer);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1620 imhtml->tip_timer = 0;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1621 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1622 if (imhtml->tip_window) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1623 gtk_widget_destroy (imhtml->tip_window);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1624 imhtml->tip_window = NULL;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1625 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1626 imhtml->tip_bit = NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1627 return TRUE;
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1628 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1629 struct imgsv {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1630 GtkWidget *savedialog;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1631 struct im_image *img;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1632 };
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1633
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1634 static void
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1635 save_img (GtkObject *object,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1636 gpointer data)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1637 {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1638 struct imgsv *is = data;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1639 struct im_image *img = is->img;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1640 gchar *filename;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1641 FILE *f;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1642 filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(is->savedialog));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1643 g_print("Saving %s\n", filename);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1644 if (! (f=fopen(filename, "w"))) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1645 /* There should be some sort of dialog */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1646 g_print("Could not open file for writing.\n");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1647 gtk_widget_destroy(is->savedialog);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1648 g_free(is);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1649 return;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1650 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1651
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1652 fwrite(img->data, 1, img->len, f);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1653 fclose(f);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1654 gtk_widget_destroy(is->savedialog);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1655 g_free(is);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1656 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1657
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1658 static void
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1659 save_img_dialog (GtkObject *object,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1660 gpointer data)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1661 {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1662 struct imgsv *is = g_malloc(sizeof(struct imgsv));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1663 struct im_image *img = data;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1664 GtkWidget *savedialog = gtk_file_selection_new ("Gaim - Save Image");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1665 gtk_file_selection_set_filename (GTK_FILE_SELECTION(savedialog), img->filename);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1666 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(savedialog)->cancel_button),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1667 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1668 (gpointer) savedialog);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1669
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1670 is->img = img;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1671 is->savedialog = savedialog;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1672
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1673 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(savedialog)->ok_button),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1674 "clicked", GTK_SIGNAL_FUNC (save_img), is);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1675 gtk_widget_show (savedialog);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1676
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1677
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1678 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1679
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1680
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1681 static void
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1682 menu_open_url (GtkObject *object,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1683 gpointer data)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1684 {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1685 struct clickable *uw = data;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1686
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1687 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
1688 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1689
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1690 static void
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1691 menu_copy_link (GtkObject *object,
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1692 gpointer data)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1693 {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1694 struct clickable *uw = data;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1695 GtkIMHtml *imhtml = uw->imhtml;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1696
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1697 if (imhtml->selected_text)
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1698 g_string_free (imhtml->selected_text, TRUE);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1699
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1700 gtk_imhtml_select_none (uw->imhtml);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1701
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1702 imhtml->selection = TRUE;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1703 imhtml->selected_text = g_string_new (uw->bit->url);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1704
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1705 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
1706 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1707
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1708 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 gtk_imhtml_button_press_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1710 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1711 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1715 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1716
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1717 x = event->x + hadj->value;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1718 y = event->y + vadj->value;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1719
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 if (event->button == 1) {
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1721 imhtml->sel_startx = imhtml->sel_endx = x;
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1722 imhtml->sel_starty = imhtml->sel_endy = y;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 imhtml->selection = TRUE;
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1724 if (event->type == GDK_BUTTON_PRESS) {
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1725 imhtml->sel_mode = 0; /* select by letter */
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1726 gtk_imhtml_select_none (imhtml);
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1727 } else if (event->type == GDK_2BUTTON_PRESS) {
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1728 imhtml->sel_mode = 1; /* select by word */
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1729 gtk_imhtml_select_none (imhtml);
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1730 } else if (event->type == GDK_3BUTTON_PRESS) {
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1731 imhtml->sel_mode = 2; /* select by line */
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1732 gtk_imhtml_select_bits (imhtml);
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1733 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1735
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1736 if (event->button == 3) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1737 GList *click = imhtml->click;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1738 struct clickable *uw;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1739
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1740 while (click) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1741 uw = click->data;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1742 if ((x > uw->x) && (x < uw->x + uw->width) &&
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1743 (y > uw->y) && (y < uw->y + uw->height)) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1744 GtkWidget *menu = gtk_menu_new ();
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1745 GtkWidget *button;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1746
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1747 if (uw->bit->url) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1748 button = gtk_menu_item_new_with_label ("Open URL");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1749 gtk_signal_connect (GTK_OBJECT (button), "activate",
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1750 GTK_SIGNAL_FUNC (menu_open_url), uw);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1751 gtk_menu_append (GTK_MENU (menu), button);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1752 gtk_widget_show (button);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1753
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1754 button = gtk_menu_item_new_with_label ("Copy Link Location");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1755 gtk_signal_connect (GTK_OBJECT (button), "activate",
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1756 GTK_SIGNAL_FUNC (menu_copy_link), uw);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1757 gtk_menu_append (GTK_MENU (menu), button);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1758 gtk_widget_show (button);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1759 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1760
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1761 if (uw->bit->img) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1762 button = gtk_menu_item_new_with_label ("Save Image");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1763 gtk_signal_connect (GTK_OBJECT (button), "activate",
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1764 GTK_SIGNAL_FUNC (save_img_dialog), uw->bit->img);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1765 gtk_menu_append (GTK_MENU (menu), button);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1766 gtk_widget_show (button);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1767 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
1768
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1769 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, event->time);
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1770
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1771 if (imhtml->tip_timer) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1772 gtk_timeout_remove (imhtml->tip_timer);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1773 imhtml->tip_timer = 0;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1774 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1775 if (imhtml->tip_window) {
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1776 gtk_widget_destroy (imhtml->tip_window);
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1777 imhtml->tip_window = NULL;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1778 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1779 imhtml->tip_bit = NULL;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1780
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1781 return TRUE;
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1782 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1783 click = g_list_next (click);
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1784 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1785 }
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
1786
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1787 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1788 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1789
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1790 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1791 gtk_imhtml_button_release_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1792 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1793 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1794 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1795 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1796 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1797 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1798
1456
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1799 x = event->x + hadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1800 y = event->y + vadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1801
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802 if ((event->button == 1) && imhtml->selection) {
2982
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1803 if ((x == imhtml->sel_startx) && (y == imhtml->sel_starty) &&
73f303cb91c1 [gaim-migrate @ 2995]
Rob Flynn <gaim@robflynn.com>
parents: 2954
diff changeset
1804 (imhtml->sel_mode == 0)) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 imhtml->sel_startx = imhtml->sel_starty = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1806 imhtml->selection = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1807 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1810 imhtml->sel_endy = MAX (y, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811 gtk_imhtml_select_bits (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1812 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1813
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1814 gtk_selection_owner_set (widget, GDK_SELECTION_PRIMARY, event->time);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1816
1547
7b50a08090a2 [gaim-migrate @ 1557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1528
diff changeset
1817 if ((event->button == 1) && (imhtml->sel_startx == 0)) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1818 GList *click = imhtml->click;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1819 struct clickable *uw;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1820
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1821 while (click) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1822 uw = (struct clickable *) click->data;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1823 if ((x > uw->x) && (x < uw->x + uw->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1824 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1825 gtk_signal_emit (GTK_OBJECT (imhtml), signals [URL_CLICKED],
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1826 uw->bit->url);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1827 return TRUE;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1828 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
1829 click = g_list_next (click);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1830 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1831 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1832
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 return TRUE;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1836 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1837 gtk_imhtml_selection_get (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1838 GtkSelectionData *sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1839 guint sel_info,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840 guint32 time)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1841 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1842 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1843 gchar *string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1844 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1845
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1846 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1847 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1848 g_return_if_fail (sel_data->selection == GDK_SELECTION_PRIMARY);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1849
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1850 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1851
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1852 g_return_if_fail (imhtml->selected_text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1853 g_return_if_fail (imhtml->selected_text->str != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1854
2188
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1855 if (imhtml->selected_text->len <= 0)
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1856 return;
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1857
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1858 string = g_strdup (imhtml->selected_text->str);
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1859 length = strlen (string);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1860
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1861 if (sel_info == TARGET_STRING) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1862 gtk_selection_data_set (sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1863 GDK_SELECTION_TYPE_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1864 8 * sizeof (gchar),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1865 (guchar *) string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1866 length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1867 } else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1868 guchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1869 GdkAtom encoding;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1870 gint format;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1871 gint new_length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 gdk_string_to_compound_text (string, &encoding, &format, &text, &new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1874 gtk_selection_data_set (sel_data, encoding, format, text, new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1875 gdk_free_compound_text (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1876 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1877
2188
98c434792ab7 [gaim-migrate @ 2198]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2140
diff changeset
1878 g_free (string);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1879 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1880
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1881 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1882 gtk_imhtml_selection_clear_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1883 GdkEventSelection *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1884 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1885 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1886
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1887 g_return_val_if_fail (widget != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1888 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1889 g_return_val_if_fail (event != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1890 g_return_val_if_fail (event->selection == GDK_SELECTION_PRIMARY, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1891
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892 if (!gtk_selection_clear (widget, event))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1893 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1894
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1895 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1896
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1898
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1899 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1900 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1901
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1902 static void
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1903 gtk_imhtml_adjustment_changed (GtkAdjustment *adjustment,
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1904 GtkIMHtml *imhtml)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1905 {
1980
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1906 GtkLayout *layout = GTK_LAYOUT (imhtml);
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1907
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1908 if (!GTK_WIDGET_MAPPED (imhtml) || !GTK_WIDGET_REALIZED (imhtml))
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1909 return;
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1910
5b79252ea95c [gaim-migrate @ 1990]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1979
diff changeset
1911 if (layout->freeze_count)
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1912 return;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1913
2809
c479d54abc0a [gaim-migrate @ 2822]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2779
diff changeset
1914 if (layout->vadjustment->value < TOP_BORDER)
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
1915 gdk_window_clear_area (layout->bin_window, 0, 0,
2809
c479d54abc0a [gaim-migrate @ 2822]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2779
diff changeset
1916 imhtml->xsize, TOP_BORDER - layout->vadjustment->value);
1961
0a3edeba05b6 [gaim-migrate @ 1971]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1955
diff changeset
1917
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1918 gtk_imhtml_draw_exposed (imhtml);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1919 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1920
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1921 static void
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1922 gtk_imhtml_set_scroll_adjustments (GtkLayout *layout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1923 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1924 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1925 {
1955
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1926 gboolean need_adjust = FALSE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1927
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1928 g_return_if_fail (layout != NULL);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1929 g_return_if_fail (GTK_IS_IMHTML (layout));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1930
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1931 if (hadj)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1932 g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1933 else
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1934 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
1935 if (vadj)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1936 g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1937 else
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1938 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
1939
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1940 if (layout->hadjustment && (layout->hadjustment != hadj)) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1941 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->hadjustment), layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1942 gtk_object_unref (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1943 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1944
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1945 if (layout->vadjustment && (layout->vadjustment != vadj)) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1946 gtk_signal_disconnect_by_data (GTK_OBJECT (layout->vadjustment), layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1947 gtk_object_unref (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1948 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1949
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1950 if (layout->hadjustment != hadj) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1951 layout->hadjustment = hadj;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1952 gtk_object_ref (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1953 gtk_object_sink (GTK_OBJECT (layout->hadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1954
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1955 gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed",
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1956 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1957 need_adjust = TRUE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1958 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1959
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1960 if (layout->vadjustment != vadj) {
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1961 layout->vadjustment = vadj;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1962 gtk_object_ref (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1963 gtk_object_sink (GTK_OBJECT (layout->vadjustment));
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1964
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1965 gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed",
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1966 (GtkSignalFunc) gtk_imhtml_adjustment_changed, layout);
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1967 need_adjust = TRUE;
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1968 }
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1969
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1970 if (need_adjust)
9ed99b8c5c9c [gaim-migrate @ 1965]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1780
diff changeset
1971 gtk_imhtml_adjustment_changed (NULL, GTK_IMHTML (layout));
1428
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975 gtk_imhtml_class_init (GtkIMHtmlClass *class)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976 {
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1977 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1978 GObjectClass *gobject_class;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1979 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980 GtkObjectClass *object_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 GtkWidgetClass *widget_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 GtkLayoutClass *layout_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1984 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1985 gobject_class = (GObjectClass*) class;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1986 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1987 object_class = (GtkObjectClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1988 widget_class = (GtkWidgetClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1989 layout_class = (GtkLayoutClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1990
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1991 parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1993 signals [URL_CLICKED] =
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 gtk_signal_new ("url_clicked",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1995 GTK_RUN_FIRST,
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
1996 GTK_CLASS_TYPE (object_class),
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1997 GTK_SIGNAL_OFFSET (GtkIMHtmlClass, url_clicked),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1998 gtk_marshal_NONE__POINTER,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1999 GTK_TYPE_NONE, 1,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2000 GTK_TYPE_POINTER);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
2002 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
2003 gobject_class->finalize = gtk_imhtml_finalize;
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
2004 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2005 gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
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 object_class->destroy = gtk_imhtml_destroy;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
2008 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2010 widget_class->realize = gtk_imhtml_realize;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
2011 #if !GTK_CHECK_VERSION(1,3,0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012 widget_class->draw = gtk_imhtml_draw;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2013 widget_class->draw_focus = gtk_imhtml_draw_focus;
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
2014 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015 widget_class->style_set = gtk_imhtml_style_set;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2016 widget_class->expose_event = gtk_imhtml_expose_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2017 widget_class->size_allocate = gtk_imhtml_size_allocate;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018 widget_class->motion_notify_event = gtk_imhtml_motion_notify_event;
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
2019 widget_class->leave_notify_event = gtk_imhtml_leave_notify_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2020 widget_class->button_press_event = gtk_imhtml_button_press_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2021 widget_class->button_release_event = gtk_imhtml_button_release_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2022 widget_class->selection_get = gtk_imhtml_selection_get;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2023 widget_class->selection_clear_event = gtk_imhtml_selection_clear_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2024
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2025 layout_class->set_scroll_adjustments = gtk_imhtml_set_scroll_adjustments;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2026 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2027
2861
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2028 /* the font stuff is the most insane stuff. i don't understand it half
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2029 * the time. so we're going to comment it. isn't that wonderful. */
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2030
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2031 /* when you g_strsplit a valid font name, these are the positions of all the various parts of it. */
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2032 #define FNDRY 1
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2033 #define FMLY 2
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2034 #define WGHT 3
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2035 #define SLANT 4
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2036 #define SWDTH 5
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2037 #define ADSTYL 6
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2038 #define PXLSZ 7
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2039 #define PTSZ 8
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2040 #define RESX 9
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2041 #define RESY 10
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2042 #define SPC 11
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2043 #define AVGWDTH 12
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2044 #define RGSTRY 13
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2045 #define ENCDNG 14
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2046
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2047 static gchar*
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2048 gtk_imhtml_get_font_name (GdkFont *font)
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2049 {
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2050 #if GTK_CHECK_VERSION(1,3,0)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2051 return "--*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*";
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2052 #else
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2053 GdkFontPrivate *fontpriv = (GdkFontPrivate *) font;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2054 return fontpriv->names->data;
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2055 #endif
1978
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2056 }
a7bfa23e80a1 [gaim-migrate @ 1988]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1964
diff changeset
2057
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058 static GdkFont*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059 gtk_imhtml_font_load (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060 gchar *name,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2061 gboolean bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2062 gboolean italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063 gint fontsize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2064 {
2691
b5698b2cad87 [gaim-migrate @ 2704]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2690
diff changeset
2065 GdkFont *default_font = imhtml->default_font;
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2066 gchar *default_name;
2714
8074f7ae5d3a [gaim-migrate @ 2727]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2705
diff changeset
2067 gchar **xnames;
8074f7ae5d3a [gaim-migrate @ 2727]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2705
diff changeset
2068 gchar **pos;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2069 gchar *tmp = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2070 GdkFont *ret_font;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2071 gchar *xname;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2072 gchar **xflds;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2073 gchar **newvals;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2074 gchar **names = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2075
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2076 char *italicstrings[] = {"i","o","*"};
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2077 int italicsind = 0, nameind = 0;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2078 gboolean usebold = TRUE, usesize = TRUE, useregenc = TRUE;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2079
2861
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2080 /* if we're not changing anything, use the default. this is the common case */
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2081 if (!name && !bold && !italics && !fontsize)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2082 return gdk_font_ref (default_font);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2083
2861
5d7e0a730c7f [gaim-migrate @ 2874]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2859
diff changeset
2084 /* base things off of the default font name */
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
2085 default_name = gtk_imhtml_get_font_name (default_font);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2086 /* the default font name can actually be several names separated by ','.
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2087 * This is a fontset... used in foreign encodings. */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2088 do {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2089 xnames = g_strsplit (default_name, ",", -1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2090 for (pos = xnames; pos && *pos; pos++) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2091 gint i, j;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2092 gchar fs[10];
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2093 gchar *garbage;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2094 xname = *pos;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2095 xname = g_strchomp (xname);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2096 xname = g_strchug (xname);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2097
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2098 xflds = g_strsplit (xname, "-", -1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2099
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2100 /* figure out if we have a valid name. i wish there were an
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2101 * easier way for determining how many values g_strplit gave */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2102 for (i = 0; xflds [i]; i++);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2103 if (i != 15) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2104 int tmp;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2105 newvals = g_malloc0 (16 * sizeof (gchar *));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2106 newvals [0] = "";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2107 for (tmp = 1; tmp < 15; tmp++)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2108 newvals [tmp] = "*";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2109 } else
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2110 newvals = g_memdup (xflds, 16 * sizeof (xflds));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2111
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2112 /* we force foundry as "*" because i hate them. i should give a better reason. */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2113 newvals [FNDRY] = "*";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2114
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2115 /* if it's "*" then it defaults to (nil) anyway. some fonts don't want (nil) */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2116 if ((i > ADSTYL) && !xflds [ADSTYL][0])
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2117 newvals [ADSTYL] = "*";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2118
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2119 /* If the font doesn't work the first time, we try it with
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2120 * registry and encoding as "*" */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2121 if (!useregenc) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2122 newvals [RGSTRY] = "*";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2123 newvals [ENCDNG] = "*";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2124 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2125 /* right. */
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2126 if (usebold && bold)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2127 newvals [WGHT] = "bold";
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2128 else if (!usebold)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2129 newvals [WGHT] = "*";
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2130
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2131 if (italics)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2132 /* We'll try "i" "o" to get italics and then just use "*" */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2133 newvals [SLANT] = italicstrings[italicsind];
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2134
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2135 if (usesize && fontsize) {
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2136 g_snprintf (fs, sizeof (fs), "%d", POINT_SIZE (fontsize));
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2137 newvals [PTSZ] = fs;
3007
206bf0e4d560 [gaim-migrate @ 3020]
Sean Egan <seanegan@gmail.com>
parents: 3004
diff changeset
2138 newvals [PXLSZ] = "*";
206bf0e4d560 [gaim-migrate @ 3020]
Sean Egan <seanegan@gmail.com>
parents: 3004
diff changeset
2139 } else if (!usesize) {
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2140 newvals [PTSZ] = "*";
3007
206bf0e4d560 [gaim-migrate @ 3020]
Sean Egan <seanegan@gmail.com>
parents: 3004
diff changeset
2141 newvals [PXLSZ] = "*";
206bf0e4d560 [gaim-migrate @ 3020]
Sean Egan <seanegan@gmail.com>
parents: 3004
diff changeset
2142 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2143
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2144 if (name) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2145 /* we got passed a name. it might be a list of names. */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2146 gchar **tmp_nms = g_strsplit (name, ",", -1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2147 for (j = 0; tmp_nms [j]; j++);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2148 names = g_new0 (char *, j + 2);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2149 for (j = 0; tmp_nms [j]; j++)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2150 names [j] = tmp_nms [j];
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2151 g_free (tmp_nms);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2152 /* Put the default font on the array. */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2153 if (i > FMLY) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2154 names [j] = g_strdup (xflds [FMLY]);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2155 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2156 newvals [FMLY] = names[nameind];
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2157 } else if (i > FMLY) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2158 /* we didn't get a name. we come here if the gtk font name is valid */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2159 names = g_new0 (gchar *, 2);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2160 names [0] = g_strdup (xflds [FMLY]);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2161 } else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2162 /* we got fucked */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2163 names = g_new0 (gchar *, 2);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2164 names [0] = g_strdup ("*");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2165 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2166 if (!tmp)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2167 tmp = g_strjoinv("-", newvals);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2168 else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2169 /* We have to concat the xlfds in the fontset */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2170 garbage = tmp;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2171 tmp = g_strconcat(garbage, ",",
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2172 g_strjoinv ("-", newvals), NULL);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2173 g_free(garbage);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2174 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2175 g_free (newvals);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2176 g_strfreev (xflds);
2714
8074f7ae5d3a [gaim-migrate @ 2727]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2705
diff changeset
2177 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2178 g_strfreev (xnames);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2179
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2180 if (default_font->type == GDK_FONT_FONT)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2181 ret_font = gdk_font_load (tmp);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2182 else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2183 /* For some reason, fontsets must end with a single * as an xlfd */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2184 gchar *garbage = tmp;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2185 tmp = g_strconcat(garbage, ",*", NULL);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2186 ret_font = gdk_fontset_load (tmp);
2714
8074f7ae5d3a [gaim-migrate @ 2727]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2705
diff changeset
2187 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2188 /* If the font didn't load, we change some of the xlfds one by one
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2189 * to get the closest we can. */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2190 if (!ret_font) {
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2191 if (useregenc) {
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2192 useregenc = FALSE;
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2193 } else if (italics && italicsind != 2) {
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2194 useregenc = TRUE;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2195 italicsind++;
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2196 } else if (bold && usebold) {
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2197 useregenc = TRUE;
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2198 italicsind=0;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2199 usebold = FALSE;
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2200 } else if (usesize) {
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2201 useregenc = TRUE;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2202 italicsind = 0;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2203 usebold = TRUE;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2204 usesize = FALSE;
3007
206bf0e4d560 [gaim-migrate @ 3020]
Sean Egan <seanegan@gmail.com>
parents: 3004
diff changeset
2205 } else if (names && names[nameind++]) {
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2206 useregenc = TRUE;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2207 italicsind = 0;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2208 usebold = TRUE;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2209 usesize = TRUE;
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2210 } else {
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
2211 ret_font = gdk_font_ref(default_font);
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2212 }
2714
8074f7ae5d3a [gaim-migrate @ 2727]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2705
diff changeset
2213 }
8074f7ae5d3a [gaim-migrate @ 2727]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2705
diff changeset
2214 g_strfreev (names);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2215 names = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2216 g_free(tmp);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2217 tmp=NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2218 } while (!ret_font); /* Loop with the new options */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2219 return ret_font;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2221
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2222 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2223 gtk_imhtml_init (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2224 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2225 static const GtkTargetEntry targets [] = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2226 { "STRING", 0, TARGET_STRING },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2227 { "TEXT", 0, TARGET_TEXT },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2228 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2229 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2230
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2232 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2237
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238 GtkType
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 gtk_imhtml_get_type (void)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 static GtkType imhtml_type = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2242
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 if (!imhtml_type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2244 static const GtkTypeInfo imhtml_info = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2245 "GtkIMHtml",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2246 sizeof (GtkIMHtml),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247 sizeof (GtkIMHtmlClass),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2248 (GtkClassInitFunc) gtk_imhtml_class_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249 (GtkObjectInitFunc) gtk_imhtml_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2250 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 NULL
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2255 imhtml_type = gtk_type_unique (GTK_TYPE_LAYOUT, &imhtml_info);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256 }
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 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261 static void
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2262 gtk_imhtml_init_smileys (GtkIMHtml *imhtml)
1428
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 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2265 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2267 imhtml->smiley_data = gtk_smiley_tree_new ();
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2268
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2269 gtk_imhtml_associate_smiley (imhtml, ":)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2270 gtk_imhtml_associate_smiley (imhtml, ":-)", smile_xpm);
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 gtk_imhtml_associate_smiley (imhtml, ":(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 gtk_imhtml_associate_smiley (imhtml, ":-(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 gtk_imhtml_associate_smiley (imhtml, ";)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 gtk_imhtml_associate_smiley (imhtml, ";-)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2278 gtk_imhtml_associate_smiley (imhtml, ":-p", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 gtk_imhtml_associate_smiley (imhtml, ":-P", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281 gtk_imhtml_associate_smiley (imhtml, "=-O", scream_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282 gtk_imhtml_associate_smiley (imhtml, ":-*", kiss_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2283 gtk_imhtml_associate_smiley (imhtml, ">:o", yell_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2284 gtk_imhtml_associate_smiley (imhtml, "8-)", smile8_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285 gtk_imhtml_associate_smiley (imhtml, ":-$", moneymouth_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286 gtk_imhtml_associate_smiley (imhtml, ":-!", burp_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2287 gtk_imhtml_associate_smiley (imhtml, ":-[", embarrassed_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 gtk_imhtml_associate_smiley (imhtml, ":'(", cry_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290 gtk_imhtml_associate_smiley (imhtml, ":-/", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 gtk_imhtml_associate_smiley (imhtml, ":-\\", think_xpm);
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 gtk_imhtml_associate_smiley (imhtml, ":-X", crossedlips_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294 gtk_imhtml_associate_smiley (imhtml, ":-D", bigsmile_xpm);
2583
ce3df2c43f46 [gaim-migrate @ 2596]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2556
diff changeset
2295 gtk_imhtml_associate_smiley (imhtml, ":-d", bigsmile_xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 gtk_imhtml_associate_smiley (imhtml, "O:-)", angel_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297 }
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 GtkWidget*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300 gtk_imhtml_new (GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303 GtkIMHtml *imhtml = gtk_type_new (GTK_TYPE_IMHTML);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2304
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 gtk_imhtml_set_adjustments (imhtml, hadj, vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2307 imhtml->im_images = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2308
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 imhtml->bits = NULL;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2310 imhtml->click = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2312 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2313 imhtml->y = TOP_BORDER;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2317
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321 imhtml->img = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 imhtml->smileys = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2324 imhtml->comments = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2326 gtk_imhtml_init_smileys (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2328 return GTK_WIDGET (imhtml);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2331 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2332 gtk_imhtml_set_adjustments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2334 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2336 gtk_layout_set_hadjustment (GTK_LAYOUT (imhtml), hadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 gtk_layout_set_vadjustment (GTK_LAYOUT (imhtml), vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2340 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 gtk_imhtml_set_defaults (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342 GdkFont *font,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2343 GdkColor *fg_color,
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2344 GdkColor *bg_color)
1428
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 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347 g_return_if_fail (GTK_IS_IMHTML (imhtml));
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 if (font) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2350 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2352 imhtml->default_font = gdk_font_ref (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353 }
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 if (fg_color) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356 if (imhtml->default_fg_color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357 gdk_color_free (imhtml->default_fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2358 imhtml->default_fg_color = gdk_color_copy (fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359 }
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2360
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2361 if (bg_color) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2362 if (imhtml->default_bg_color)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2363 gdk_color_free (imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2364 imhtml->default_bg_color = gdk_color_copy (bg_color);
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
2365 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
2366 }
1428
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 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 gtk_imhtml_set_img_handler (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2371 GtkIMHtmlImage handler)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2373 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376 imhtml->img = handler;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 gchar **xpm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2383 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386 g_return_if_fail (text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2388 if (xpm == NULL)
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2389 gtk_smiley_tree_remove (imhtml->smiley_data, text);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2390 else
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2391 gtk_smiley_tree_insert (imhtml->smiley_data, text, xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2392 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2394 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2395 new_line (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2396 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397 GList *last = g_list_last (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2401 li = last->data;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2402 if (li->x + li->width != imhtml->xsize)
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2403 li->width = imhtml->xsize - li->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2404 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406 last = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2407 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2408 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 if (li->height < MIN_HEIGHT) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2410 while (last) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 gint diff;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2412 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 diff = MIN_HEIGHT - li->height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2414 li->height = MIN_HEIGHT;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2415 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416 last = g_list_next (last);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 imhtml->llheight = MIN_HEIGHT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 }
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2422 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2423 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2425 imhtml->x = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 imhtml->y += imhtml->llheight;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2427 imhtml->llheight = 0;
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2428 imhtml->llascent = 0;
1428
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 backwards_update (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434 gint height,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 gint ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2438 GList *ls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 struct line_info *li;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2440 struct clickable *uw;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2441 struct im_image *img;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2442
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2443 if (height > imhtml->llheight) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2444 diff = height - imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2445
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2446 ls = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2447 while (ls) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2448 li = ls->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2449 li->height += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2451 li->ascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2453 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2457 ls = imhtml->click;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2458 while (ls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2459 uw = ls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2460 if (uw->y + diff > imhtml->y)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461 uw->y += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2463 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2464
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2465 ls = imhtml->im_images;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2466 while(ls) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2467 img = ls->data;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2468 if (img->y + diff > imhtml->y)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2469 img->y += diff;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2470 ls = g_list_next(ls);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2471 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2472
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 imhtml->llheight = height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2475 imhtml->llascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2477 imhtml->llascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2478 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2480
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2482 add_text_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2483 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2484 gchar *text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2485 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2486 struct line_info *li;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2487 struct clickable *uw;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2488 gint width;
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 (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 width = gdk_string_width (bit->font, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493 width = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2496 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2499 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2500 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2501 li->ascent = MAX (imhtml->llascent, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504 li->text = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2506
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2507 if (bit->url) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2508 uw = g_new0 (struct clickable, 1);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2509 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512 uw->height = imhtml->llheight;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
2513 uw->imhtml = imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
2514 uw->bit = bit;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2515 imhtml->click = g_list_append (imhtml->click, uw);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2517
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2518 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2519 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2523 add_img_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524 GtkIMHtmlBit *bit)
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 struct line_info *li;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2527 struct clickable *uw;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2528 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2529
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2530 gdk_window_get_size (bit->pm, &width, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2531
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2532 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2533 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2534 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2535 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2536 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2537 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2538 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2539
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2540
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2541 if (bit->url || bit->img) {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2542 uw = g_new0 (struct clickable, 1);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2544 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2546 uw->height = imhtml->llheight;
2655
c4ad36781d1b [gaim-migrate @ 2668]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2622
diff changeset
2547 uw->imhtml = imhtml;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
2548 uw->bit = bit;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2549 imhtml->click = g_list_append (imhtml->click, uw);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2550 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2551
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2552 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2553 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2554
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 imhtml->x += width;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2559 gtk_imhtml_draw_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2560 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2561 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2562 gint width, height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2563
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2564 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2565 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2566 g_return_if_fail (bit != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2567
2954
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
2568 if ( ((bit->type == TYPE_TEXT) ||
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2569 ((bit->type == TYPE_SMILEY) && !imhtml->smileys) ||
2954
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
2570 ((bit->type == TYPE_COMMENT) && imhtml->comments)) &&
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
2571 bit->text) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2572 gchar *copy = g_strdup (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2573 gint pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2574 gboolean seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2575 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2576
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2577 height = bit->font->ascent + bit->font->descent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2578 width = gdk_string_width (bit->font, bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2579
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2580 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize)) {
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2581 gint remain = imhtml->xsize - imhtml->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2582 while (gdk_text_width (bit->font, copy, pos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2583 if (copy [pos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2584 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2585 pos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2586 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2587 if (seenspace) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2588 while (copy [pos - 1] != ' ') pos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2589
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2590 tmp = g_strndup (copy, pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2591
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2592 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2593 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2594 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2595 pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2596 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2597 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2598 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2599
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2600 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2601
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2602 while (pos < strlen (bit->text)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2603 width = gdk_string_width (bit->font, copy + pos);
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2604 if (imhtml->x + width > imhtml->xsize) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2605 gint newpos = 0;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2606 gint remain = imhtml->xsize - imhtml->x;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2607 while (gdk_text_width (bit->font, copy + pos, newpos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2608 if (copy [pos + newpos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2609 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2610 newpos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2611 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2612
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2613 if (seenspace)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2614 while (copy [pos + newpos - 1] != ' ') newpos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2615
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2616 if (newpos == 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2617 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2618
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2619 tmp = g_strndup (copy + pos, newpos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2620 pos += newpos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2621
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2622 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2623 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2624
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2625 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2626 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2627 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2628 tmp = g_strdup (copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2629
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2630 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2631 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2632
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2633 pos = strlen (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2634
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2635 imhtml->x += width;
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2638
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2639 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2640 } else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) {
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2641 #if USE_PIXBUF
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2642 if (bit->img) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2643 GdkPixbuf *imagepb = bit->img->pb;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2644 GdkPixbuf *tmp = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2645 if (gdk_pixbuf_get_width(imagepb) > imhtml->xsize - imhtml->x)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2646 new_line (imhtml);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2647
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2648 if (gdk_pixbuf_get_width(imagepb) > imhtml->xsize) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2649 tmp = gdk_pixbuf_scale_simple(imagepb, imhtml->xsize,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2650 gdk_pixbuf_get_height(imagepb) *
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2651 imhtml->xsize/
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2652 gdk_pixbuf_get_width(imagepb),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2653 GDK_INTERP_TILES);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2654 if (bit->pm)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2655 gdk_pixmap_unref (bit->pm);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2656 if (bit->bm)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2657 gdk_bitmap_unref (bit->bm);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2658 gdk_pixbuf_render_pixmap_and_mask(tmp, &(bit->pm), &(bit->bm), 100);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2659 gdk_pixbuf_unref(tmp);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2660 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2661 else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2662 if (bit->pm)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2663 gdk_pixmap_unref (bit->pm);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2664 if (bit->bm)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2665 gdk_bitmap_unref (bit->bm);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2666 gdk_pixbuf_render_pixmap_and_mask(imagepb, &(bit->pm), &(bit->bm), 100);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2667 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2668 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2669 #endif
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
2670
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2671 gdk_window_get_size (bit->pm, &width, &height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2672
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2673 if ((imhtml->x != 0) && ((imhtml->x + width) > imhtml->xsize))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2674 new_line (imhtml);
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2675 else
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2676 backwards_update (imhtml, bit, height, 0);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2677
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2678 add_img_renderer (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2679 } else if (bit->type == TYPE_BR) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2680 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2681 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2682 } else if (bit->type == TYPE_SEP) {
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2683 struct line_info *li;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
2684 if (imhtml->llheight)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2685 new_line (imhtml);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2686
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2687 li = g_new0 (struct line_info, 1);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2688 li->x = imhtml->x;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2689 li->y = imhtml->y;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
2690 li->width = imhtml->xsize;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2691 li->height = HR_HEIGHT * 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2692 li->ascent = 0;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2693 li->text = NULL;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2694 li->bit = bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2695
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2696 bit->chunks = g_list_append (bit->chunks, li);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
2697
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2698 imhtml->llheight = HR_HEIGHT * 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2699 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2700 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2701 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2702 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2703
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2704 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2705 gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2706 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2707 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2708 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2709 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2710
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2711 imhtml->smileys = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2712
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2713 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2714 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2715 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2716
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2717 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2718 gtk_imhtml_show_comments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2719 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2720 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2721 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2722 g_return_if_fail (GTK_IS_IMHTML (imhtml));
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 imhtml->comments = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2725
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2726 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2727 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2728 }
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 static GdkColor *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2731 gtk_imhtml_get_color (const gchar *color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2732 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2733 GdkColor c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2734
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2735 if (!gdk_color_parse (color, &c))
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2736 return NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2737
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
2738 return gdk_color_copy (&c);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2739 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2740
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2741 static gboolean
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2742 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2743 const gchar *text,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2744 gint *len)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2745 {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2746 *len = gtk_smiley_tree_lookup (imhtml->smiley_data, text);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2747 return (*len > 0);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2748 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2749
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2750 static GtkIMHtmlBit *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2751 gtk_imhtml_new_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2752 gint type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2753 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2754 gint bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2755 gint italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2756 gint underline,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2757 gint strike,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2758 FontDetail *font,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2759 GdkColor *bg,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2760 gchar *url,
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2761 gint pre,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2762 gint sub,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2763 gint sup)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2764 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2765 GtkIMHtmlBit *bit = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2766
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2767 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2768 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2769
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2770 if ((type == TYPE_TEXT) && ((text == NULL) || (strlen (text) == 0)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2771 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2772
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2773 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2774 bit->type = type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2775
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2776 if ((text != NULL) && (strlen (text) != 0))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2777 bit->text = g_strdup (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2778
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2779 if ((font != NULL) || bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2780 if (font && (bold || italics || font->size || font->face || pre)) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2781 if (pre) {
2761
367d19133917 [gaim-migrate @ 2774]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2734
diff changeset
2782 bit->font = gtk_imhtml_font_load (imhtml, DEFAULT_PRE_FACE, bold, italics, font->size);
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2783 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2784 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
2785 }
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2786 } else if (bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2787 if (pre) {
2761
367d19133917 [gaim-migrate @ 2774]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2734
diff changeset
2788 bit->font = gtk_imhtml_font_load (imhtml, DEFAULT_PRE_FACE, bold, italics, 0);
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2789 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2790 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2791 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2792 }
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 if (font && (type != TYPE_BR)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2795 if (font->fore != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2796 bit->fore = gdk_color_copy (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2797
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2798 if (font->back != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2799 bit->back = gdk_color_copy (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2800 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2801 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2802
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2803 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
2804 (bit->font == NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2805 bit->font = gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2806
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2807 if (bg != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2808 bit->bg = gdk_color_copy (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2809
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2810 bit->underline = underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2811 bit->strike = strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2812
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2813 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2814 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2815
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2816 if (type == TYPE_SMILEY) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2817 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2818
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2819 if ((font != NULL) && (font->back != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2820 clr = font->back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2821 else
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2822 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2823
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2825 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2826 clr,
2349
60c716c32c40 [gaim-migrate @ 2362]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2348
diff changeset
2827 gtk_smiley_tree_image (imhtml->smiley_data, text));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2828 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2829
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2830 return bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2831 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2832
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2833 #define NEW_TEXT_BIT gtk_imhtml_new_bit (imhtml, TYPE_TEXT, ws, bold, italics, underline, strike, \
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2834 fonts ? fonts->data : NULL, bg, url, pre, sub, sup)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2835 #define NEW_SMILEY_BIT gtk_imhtml_new_bit (imhtml, TYPE_SMILEY, ws, bold, italics, underline, strike, \
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2836 fonts ? fonts->data : NULL, bg, url, pre, sub, sup)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2837 #define NEW_SEP_BIT gtk_imhtml_new_bit (imhtml, TYPE_SEP, NULL, 0, 0, 0, 0, NULL, bg, NULL, 0, 0, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2838 #define NEW_BR_BIT gtk_imhtml_new_bit (imhtml, TYPE_BR, NULL, 0, 0, 0, 0, \
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2839 fonts ? fonts->data : NULL, bg, NULL, 0, 0, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2840 #define NEW_COMMENT_BIT gtk_imhtml_new_bit (imhtml, TYPE_COMMENT, ws, bold, italics, underline, strike, \
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2841 fonts ? fonts->data : NULL, bg, url, pre, sub, sup)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2842
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2843 #define NEW_BIT(bit) ws [wpos] = '\0'; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2844 { GtkIMHtmlBit *tmp = bit; if (tmp != NULL) \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2845 newbits = g_list_append (newbits, tmp); } \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2846 wpos = 0; ws [wpos] = '\0'
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2847
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2848 #define UPDATE_BG_COLORS \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2849 { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2850 GdkColormap *cmap; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2851 GList *rev; \
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2852 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2853 rev = g_list_last (newbits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2854 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2855 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2856 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2857 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2858 bit->bg = gdk_color_copy (bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2859 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2860 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861 rev = g_list_previous (rev); \
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 if (!rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2864 rev = g_list_last (imhtml->bits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2865 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2866 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2867 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2868 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869 bit->bg = gdk_color_copy (bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2870 gdk_color_alloc (cmap, bit->bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2871 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2872 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2873 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2874 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2875 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2876 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2877
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2878 static gboolean
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2879 gtk_imhtml_is_amp_escape (const gchar *string,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2880 gchar *replace,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2881 gint *length)
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2882 {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2883 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2884 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2885 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2886
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2887 if (!g_strncasecmp (string, "&amp;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2888 *replace = '&';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2889 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2890 } else if (!g_strncasecmp (string, "&lt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2891 *replace = '<';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2892 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2893 } else if (!g_strncasecmp (string, "&gt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2894 *replace = '>';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2895 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2896 } else if (!g_strncasecmp (string, "&nbsp;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2897 *replace = ' ';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2898 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2899 } else if (!g_strncasecmp (string, "&copy;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2900 *replace = '©';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2901 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2902 } else if (!g_strncasecmp (string, "&quot;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2903 *replace = '\"';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2904 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2905 } else if (!g_strncasecmp (string, "&reg;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2906 *replace = '®';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2907 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2908 } else if (*(string + 1) == '#') {
2022
199ba82faacb [gaim-migrate @ 2032]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2002
diff changeset
2909 guint pound = 0;
3004
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 3000
diff changeset
2910 if ((sscanf (string, "&#%u;", &pound) == 1) && pound != 0) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2911 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2912 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2913 *replace = (gchar)pound;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2914 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2915 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2916 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2917 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2918 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2919 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2920 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2921 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2922 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2923
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2924 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2925 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2926
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2927 #define VALID_TAG(x) if (!g_strncasecmp (string, x ">", strlen (x ">"))) { \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2928 *tag = g_strndup (string, strlen (x)); \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2929 *len = strlen (x) + 1; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2930 return TRUE; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2931 } \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2932 (*type)++
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2933
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2934 #define VALID_OPT_TAG(x) if (!g_strncasecmp (string, x " ", strlen (x " "))) { \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2935 const gchar *c = string + strlen (x " "); \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2936 gchar e = '"'; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2937 gboolean quote = FALSE; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2938 while (*c) { \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2939 if (*c == '"' || *c == '\'') { \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2940 if (quote && (*c == e)) \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2941 quote = !quote; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2942 else if (!quote) { \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2943 quote = !quote; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2944 e = *c; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2945 } \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2946 } else if (!quote && (*c == '>')) \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2947 break; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2948 c++; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2949 } \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2950 if (*c) { \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2951 *tag = g_strndup (string, c - string); \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2952 *len = c - string + 1; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2953 return TRUE; \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2954 } \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2955 } \
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2956 (*type)++
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2957
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2958 static gboolean
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2959 gtk_imhtml_is_tag (const gchar *string,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2960 gchar **tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2961 gint *len,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2962 gint *type)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2963 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2964 *type = 1;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2965
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2966 if (!strchr (string, '>'))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2967 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2968
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2969 VALID_TAG ("B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2970 VALID_TAG ("BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2971 VALID_TAG ("/B");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2972 VALID_TAG ("/BOLD");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2973 VALID_TAG ("I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2974 VALID_TAG ("ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2975 VALID_TAG ("/I");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2976 VALID_TAG ("/ITALIC");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2977 VALID_TAG ("U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2978 VALID_TAG ("UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2979 VALID_TAG ("/U");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2980 VALID_TAG ("/UNDERLINE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2981 VALID_TAG ("S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2982 VALID_TAG ("STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2983 VALID_TAG ("/S");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2984 VALID_TAG ("/STRIKE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2985 VALID_TAG ("SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2986 VALID_TAG ("/SUB");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2987 VALID_TAG ("SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2988 VALID_TAG ("/SUP");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2989 VALID_TAG ("PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2990 VALID_TAG ("/PRE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2991 VALID_TAG ("TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2992 VALID_TAG ("/TITLE");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2993 VALID_TAG ("BR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2994 VALID_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2995 VALID_TAG ("/FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2996 VALID_TAG ("/A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2997 VALID_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2998 VALID_TAG ("/P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
2999 VALID_TAG ("H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3000 VALID_TAG ("/H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3001 VALID_TAG ("HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3002 VALID_TAG ("/HTML");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3003 VALID_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3004 VALID_TAG ("/BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3005 VALID_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3006 VALID_TAG ("HEAD");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3007 VALID_TAG ("/HEAD");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3008 VALID_TAG ("BINARY");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3009 VALID_TAG ("/BINARY");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3010
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3011 VALID_OPT_TAG ("HR");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3012 VALID_OPT_TAG ("FONT");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3013 VALID_OPT_TAG ("BODY");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3014 VALID_OPT_TAG ("A");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3015 VALID_OPT_TAG ("IMG");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3016 VALID_OPT_TAG ("P");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3017 VALID_OPT_TAG ("H3");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3018
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3019 if (!g_strncasecmp(string, "!--", strlen ("!--"))) {
2954
f6c4f2187c08 [gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents: 2898
diff changeset
3020 gchar *e = strstr (string + strlen("!--"), "-->");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3021 if (e) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3022 *len = e - string + strlen ("-->");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3023 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->"));
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3024 return TRUE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3025 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3026 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3027
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3028 return FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3029 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3030
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3031 static gchar*
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3032 gtk_imhtml_get_html_opt (gchar *tag,
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3033 const gchar *opt)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3034 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3035 gchar *t = tag;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3036 gchar *e, *a;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3037
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3038 while (g_strncasecmp (t, opt, strlen (opt))) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3039 gboolean quote = FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3040 if (*t == '\0') break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3041 while (*t && !((*t == ' ') && !quote)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3042 if (*t == '\"')
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3043 quote = ! quote;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3044 t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3045 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3046 while (*t && (*t == ' ')) t++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3047 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3048
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3049 if (!g_strncasecmp (t, opt, strlen (opt))) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3050 t += strlen (opt);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3051 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3052 return NULL;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3053 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3054
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3055 if ((*t == '\"') || (*t == '\'')) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3056 e = a = ++t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3057 while (*e && (*e != *(t - 1))) e++;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3058 if (*e == '\0') {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3059 return NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3060 } else
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3061 return g_strndup (a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3062 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3063 e = a = t;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3064 while (*e && !isspace ((gint) *e)) e++;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3065 return g_strndup (a, e - a);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3066 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3067 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3068
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3069 GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3070 gtk_imhtml_append_text (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3071 const gchar *text,
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3072 gint len,
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3073 GtkIMHtmlOptions options)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3074 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3075 const gchar *c;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3076 gboolean binary = TRUE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3077 gchar *ws;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3078 gint pos = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3079 gint wpos = 0;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3080
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3081 gchar *tag;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3082 gint tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3083 gint type;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3084
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3085 gchar amp;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3086
2871
10b808bee701 [gaim-migrate @ 2884]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2861
diff changeset
3087 gint smilelen;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3088
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3089 GList *newbits = NULL;
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 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3092 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3093 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3094 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3095 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3096 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3097 title = 0,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3098 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3099 GSList *fonts = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3100 GdkColor *bg = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3101 gchar *url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3102
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3103 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3104 gboolean scrolldown = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3105
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3106 GString *retval = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3107
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3108 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3109 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3110 g_return_val_if_fail (text != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3111
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3112 if (options & GTK_IMHTML_RETURN_LOG)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3113 retval = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3114
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3115 vadj = GTK_LAYOUT (imhtml)->vadjustment;
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3116 if ((vadj->value < imhtml->y - GTK_WIDGET (imhtml)->allocation.height) &&
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3117 (vadj->upper >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3118 scrolldown = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3119
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3120 c = text;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3121 if (len == -1) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3122 binary = FALSE;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3123 len = strlen (text);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3124 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3125
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3126 ws = g_malloc (len + 1);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3127 ws [0] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3128
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3129 while (pos < len) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3130 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3131 c++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3132 pos++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3133 switch (type) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3134 case 1: /* B */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3135 case 2: /* BOLD */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3136 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3137 bold++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3138 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3139 case 3: /* /B */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3140 case 4: /* /BOLD */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3141 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3142 if (bold)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3143 bold--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3144 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3145 case 5: /* I */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3146 case 6: /* ITALIC */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3147 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3148 italics++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3149 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3150 case 7: /* /I */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3151 case 8: /* /ITALIC */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3152 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3153 if (italics)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3154 italics--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3155 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3156 case 9: /* U */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3157 case 10: /* UNDERLINE */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3158 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3159 underline++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3160 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3161 case 11: /* /U */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3162 case 12: /* /UNDERLINE */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3163 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3164 if (underline)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3165 underline--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3166 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3167 case 13: /* S */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3168 case 14: /* STRIKE */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3169 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3170 strike++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3171 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3172 case 15: /* /S */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3173 case 16: /* /STRIKE */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3174 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3175 if (strike)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3176 strike--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3177 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3178 case 17: /* SUB */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3179 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3180 sub++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3181 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3182 case 18: /* /SUB */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3183 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3184 if (sub)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3185 sub--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3186 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3187 case 19: /* SUP */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3188 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3189 sup++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3190 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3191 case 20: /* /SUP */
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
3192 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3193 if (sup)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3194 sup--;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3195 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3196 case 21: /* PRE */
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3197 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3198 pre++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3199 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3200 case 22: /* /PRE */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3201 NEW_BIT (NEW_TEXT_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3202 if (pre)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3203 pre--;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3204 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3205 case 23: /* TITLE */
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3206 NEW_BIT (NEW_TEXT_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3207 title++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3208 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3209 case 24: /* /TITLE */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3210 if (title) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3211 if (options & GTK_IMHTML_NO_TITLE) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3212 wpos = 0;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3213 ws [wpos] = '\0';
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3214 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3215 title--;
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3216 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3217 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3218 case 25: /* BR */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3219 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3220 NEW_BIT (NEW_BR_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3221 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3222 case 26: /* HR */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3223 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3224 NEW_BIT (NEW_SEP_BIT);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3225 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3226 case 27: /* /FONT */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3227 if (fonts) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3228 FontDetail *font = fonts->data;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3229 NEW_BIT (NEW_TEXT_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3230 fonts = g_slist_remove (fonts, font);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3231 if (font->face)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3232 g_free (font->face);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3233 if (font->fore)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3234 gdk_color_free (font->fore);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3235 if (font->back)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3236 gdk_color_free (font->back);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3237 g_free (font);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3238 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3239 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3240 case 28: /* /A */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3241 if (url) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3242 NEW_BIT (NEW_TEXT_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3243 g_free (url);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3244 url = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3245 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3246 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3247 case 29: /* P */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3248 case 30: /* /P */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3249 case 31: /* H3 */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3250 case 32: /* /H3 */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3251 case 33: /* HTML */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3252 case 34: /* /HTML */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3253 case 35: /* BODY */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3254 case 36: /* /BODY */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3255 case 37: /* FONT */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3256 case 38: /* HEAD */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3257 case 39: /* /HEAD */
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3258 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3259 case 40: /* BINARY */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3260
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3261 NEW_BIT (NEW_TEXT_BIT);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3262 while (pos < len) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3263 if (!g_strncasecmp("</BINARY>", c, strlen("</BINARY>")))
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3264 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3265 else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3266 c++;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3267 pos++;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3268 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3269 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3270 c = c - tlen; /* Because it will add this later */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3271 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3272 case 41: /* /BINARY */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3273 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3274
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3275 case 42: /* HR (opt) */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3276 NEW_BIT (NEW_TEXT_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3277 NEW_BIT (NEW_SEP_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3278 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3279 case 43: /* FONT (opt) */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3280 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3281 gchar *color, *back, *face, *size;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3282 FontDetail *font;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3283
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3284 color = gtk_imhtml_get_html_opt (tag, "COLOR=");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3285 back = gtk_imhtml_get_html_opt (tag, "BACK=");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3286 face = gtk_imhtml_get_html_opt (tag, "FACE=");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3287 size = gtk_imhtml_get_html_opt (tag, "SIZE=");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3288
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3289 if (!(color || back || face || size))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3290 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3291
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
3292 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3293
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3294 font = g_new0 (FontDetail, 1);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3295 if (color && !(options & GTK_IMHTML_NO_COLOURS))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3296 font->fore = gtk_imhtml_get_color (color);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3297 if (back && !(options & GTK_IMHTML_NO_COLOURS))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3298 font->back = gtk_imhtml_get_color (back);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3299 if (face && !(options & GTK_IMHTML_NO_FONTS))
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3300 font->face = g_strdup (face);
2898
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3301 if (size && !(options & GTK_IMHTML_NO_SIZES)) {
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3302 if (*size == '+') {
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3303 sscanf (size + 1, "%hd", &font->size);
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3304 font->size += 3;
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3305 } else if (*size == '-') {
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3306 sscanf (size + 1, "%hd", &font->size);
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3307 font->size = MAX (0, 3 - font->size);
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3308 } else if (isdigit (*size)) {
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3309 sscanf (size, "%hd", &font->size);
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3310 }
eef6c9ca18c9 [gaim-migrate @ 2911]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2897
diff changeset
3311 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3312
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3313 g_free (color);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3314 g_free (back);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3315 g_free (face);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3316 g_free (size);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3317
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3318 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3319 FontDetail *oldfont = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3320 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3321 font->size = oldfont->size;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3322 if (!font->face && oldfont->face)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3323 font->face = g_strdup (oldfont->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3324 if (!font->fore && oldfont->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3325 font->fore = gdk_color_copy (oldfont->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3326 if (!font->back && oldfont->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3327 font->back = gdk_color_copy (oldfont->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3328 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3329
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3330 fonts = g_slist_prepend (fonts, font);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3331 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3332 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3333 case 44: /* BODY (opt) */
2885
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3334 if (!(options & GTK_IMHTML_NO_COLOURS)) {
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3335 gchar *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR=");
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3336 if (bgcolor) {
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3337 GdkColor *tmp = gtk_imhtml_get_color (bgcolor);
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3338 g_free (bgcolor);
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3339 if (tmp) {
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3340 NEW_BIT (NEW_TEXT_BIT);
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3341 bg = tmp;
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3342 UPDATE_BG_COLORS;
f72efa29c109 [gaim-migrate @ 2898]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2871
diff changeset
3343 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3344 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3345 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3346 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3347 case 45: /* A (opt) */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3348 {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3349 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF=");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3350 if (href) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3351 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3352 g_free (url);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3353 url = href;
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
3354 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3355 }
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3356 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3357 case 46: /* IMG (opt) */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3358 {
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3359 gchar *src = gtk_imhtml_get_html_opt (tag, "SRC=");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3360 gchar *id = gtk_imhtml_get_html_opt (tag, "ID=");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3361 gchar *datasize = gtk_imhtml_get_html_opt (tag, "DATASIZE=");
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3362 gchar **xpm;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3363 GdkColor *clr;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3364 GtkIMHtmlBit *bit;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3365
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3366 if (!src)
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3367 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3368
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3369 if (!imhtml->img && id && datasize) { /* This is an embedded IM image */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3370 char *tmp, *imagedata, *e;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3371 const gchar *alltext;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3372 struct im_image *img;
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3373 #if USE_PIXBUF
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3374 GdkPixbufLoader *load;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3375 GdkPixbuf *imagepb = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3376 #endif
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3377 NEW_BIT (NEW_TEXT_BIT);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3378 if (!id || !datasize)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3379 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3380 tmp = g_malloc(strlen("<DATA ID=\"\" SIZE=\"\">") +
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3381 strlen(id) + strlen(datasize));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3382 g_snprintf(tmp, strlen("<DATA ID=\"\" SIZE=\"\">") +
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3383 strlen(id) + strlen(datasize) + 1,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3384 "<DATA ID=\"%s\" SIZE=\"%s\">", id, datasize);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3385 alltext = c;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3386 while (g_strncasecmp(alltext, tmp, strlen(tmp)) && alltext < (c + len))
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3387 alltext++;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3388 alltext = alltext + strlen("<DATA ID=\"\" SIZE=\"\">") + strlen(id) + strlen(datasize);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3389 g_free(tmp);
3010
11827e3d714c [gaim-migrate @ 3023]
Sean Egan <seanegan@gmail.com>
parents: 3007
diff changeset
3390 if (atoi(datasize) > len - pos)
11827e3d714c [gaim-migrate @ 3023]
Sean Egan <seanegan@gmail.com>
parents: 3007
diff changeset
3391 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3392 imagedata = g_malloc(atoi(datasize));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3393 memcpy(imagedata, alltext, atoi(datasize));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3394
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3395 if (!GTK_WIDGET_REALIZED (imhtml))
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3396 gtk_widget_realize (GTK_WIDGET (imhtml));
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3397
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3398 img = g_new0 (struct im_image, 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3399 tmp = e = src;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3400 while (*tmp){
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3401 if (*tmp == '/' || *tmp == '\\') {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3402 tmp++;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3403 src = tmp;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3404 } else
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3405 tmp++;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3406 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3407
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3408 *tmp = '\0';
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3409
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3410 img->filename = g_strdup(src);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3411 img->len = atoi(datasize);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3412 if (img->len) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3413 img->data = g_malloc(img->len);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3414 memcpy(img->data, imagedata, img->len);
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3415 #if USE_PIXBUF
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3416 load = gdk_pixbuf_loader_new();
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3417 if (!gdk_pixbuf_loader_write(load, imagedata, img->len))
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3418 g_print("IM Image corrupt or unreadable.\n");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3419 else
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3420 imagepb = gdk_pixbuf_loader_get_pixbuf(load);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3421 img->pb = imagepb;
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3422 #endif
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3423 }
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3424 #if USE_PIXBUF
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3425 if (imagepb) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3426 bit = g_new0 (GtkIMHtmlBit, 1);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3427 bit->type = TYPE_IMG;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3428 bit->img = img;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3429 if (url)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3430 bit->url = g_strdup (url);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3431
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3432 NEW_BIT (bit);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3433 } else {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3434 g_free(img->filename);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3435 g_free(img->data);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3436 }
2994
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3437 #else
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3438 bit = g_new0 (GtkIMHtmlBit, 1);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3439 bit->type = TYPE_IMG;
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3440 bit->img = img;
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3441 if (url)
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3442 bit->url = g_strdup (url);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3443 if (!fonts || ((clr = ((FontDetail *) fonts->data)->back) == NULL))
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3444 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3445
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3446 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3447 &bit->bm, clr, broken_xpm);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3448 NEW_BIT (bit);
60018f862a51 [gaim-migrate @ 3007]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
3449 #endif
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3450 g_free(imagedata);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3451 g_free(e);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3452 g_free(id);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3453 g_free(datasize);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3454
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3455 break;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3456 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3457
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3458 if (!imhtml->img || ((xpm = imhtml->img (src)) == NULL)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3459 g_free (src);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3460 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3461 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3462
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3463 if (!fonts || ((clr = ((FontDetail *) fonts->data)->back) == NULL))
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
3464 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3465
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3466 if (!GTK_WIDGET_REALIZED (imhtml))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3467 gtk_widget_realize (GTK_WIDGET (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3468
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3469 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3470 bit->type = TYPE_IMG;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3471 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3472 &bit->bm, clr, xpm);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3473 if (url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3474 bit->url = g_strdup (url);
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 NEW_BIT (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3477
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3478 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3479 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3480 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3481 case 47: /* P (opt) */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3482 case 48: /* H3 (opt) */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3483 break;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3484 case 49: /* comment */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3485 NEW_BIT (NEW_TEXT_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3486 wpos = g_snprintf (ws, len, "%s", tag);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3487 NEW_BIT (NEW_COMMENT_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3488 break;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3489 default:
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3490 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3491 }
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3492 g_free (tag);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3493 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3494 pos += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3495 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &amp, &tlen)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3496 ws [wpos++] = amp;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3497 c += tlen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3498 pos += tlen;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3499 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3500 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3501 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3502 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3503 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3504 c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3505 pos++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3506 } else if (gtk_imhtml_is_smiley (imhtml, c, &smilelen)) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3507 NEW_BIT (NEW_TEXT_BIT);
2871
10b808bee701 [gaim-migrate @ 2884]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2861
diff changeset
3508 wpos = g_snprintf (ws, smilelen + 1, "%s", c);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3509 NEW_BIT (NEW_SMILEY_BIT);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3510 c += smilelen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3511 pos += smilelen;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3512 } else if (*c) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3513 ws [wpos++] = *c++;
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3514 pos++;
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3515 } else {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3516 break;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3517 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3518 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3519
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3520 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3521
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3522 while (newbits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3523 GtkIMHtmlBit *bit = newbits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3524 imhtml->bits = g_list_append (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3525 newbits = g_list_remove (newbits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3526 gtk_imhtml_draw_bit (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3527 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3528
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3529 GTK_LAYOUT (imhtml)->height = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3530 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3531 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
3532
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3533 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3534
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3535 #if GTK_CHECK_VERSION(1,3,0)
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3536 if (!(options & GTK_IMHTML_NO_SCROLL) &&
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3537 scrolldown &&
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3538 (imhtml->y >= MAX (1,
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3539 (GTK_WIDGET (imhtml)->allocation.height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3540 (GTK_WIDGET (imhtml)->style->ythickness + BORDER_SIZE) * 2))))
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3541 gtk_adjustment_set_value (vadj, imhtml->y -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3542 MAX (1, (GTK_WIDGET (imhtml)->allocation.height -
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3543 (GTK_WIDGET (imhtml)->style->ythickness +
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3544 BORDER_SIZE) * 2)));
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3545 #else
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3546 if (!(options & GTK_IMHTML_NO_SCROLL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3547 scrolldown &&
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3548 (imhtml->y >= MAX (1,
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3549 (GTK_WIDGET (imhtml)->allocation.height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3550 (GTK_WIDGET (imhtml)->style->klass->ythickness + BORDER_SIZE) * 2))))
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3551 gtk_adjustment_set_value (vadj, imhtml->y -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3552 MAX (1, (GTK_WIDGET (imhtml)->allocation.height -
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3553 (GTK_WIDGET (imhtml)->style->klass->ythickness +
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3554 BORDER_SIZE) * 2)));
2671
ffa58bbe595d [gaim-migrate @ 2684]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2655
diff changeset
3555 #endif
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3556
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3557 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3558 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3559 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3560 retval = g_string_append (retval, "</A>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3561 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3562 if (bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3563 gdk_color_free (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3564 while (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3565 FontDetail *font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3566 fonts = g_slist_remove (fonts, font);
2690
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3567 if (font->face)
5a207e155c15 [gaim-migrate @ 2703]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2671
diff changeset
3568 g_free (font->face);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3569 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3570 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3571 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3572 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3573 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3574 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3575 retval = g_string_append (retval, "</FONT>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3576 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3577 if (retval) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3578 while (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3579 retval = g_string_append (retval, "</B>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3580 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3581 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3582 while (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3583 retval = g_string_append (retval, "</I>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3584 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3585 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3586 while (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3587 retval = g_string_append (retval, "</U>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3588 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3589 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3590 while (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3591 retval = g_string_append (retval, "</S>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3592 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3593 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3594 while (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3595 retval = g_string_append (retval, "</SUB>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3596 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3597 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3598 while (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3599 retval = g_string_append (retval, "</SUP>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3600 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3601 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3602 while (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3603 retval = g_string_append (retval, "</TITLE>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3604 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3605 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3606 while (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3607 retval = g_string_append (retval, "</PRE>");
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3608 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
3609 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3610 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3611 g_free (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3612
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3613 return retval;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3614 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3615
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3616 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3617 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3618 {
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3619 GtkLayout *layout;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3620
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3621 g_return_if_fail (imhtml != NULL);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3622 g_return_if_fail (GTK_IS_IMHTML (imhtml));
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3623
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3624 layout = GTK_LAYOUT (imhtml);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3625
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3626 while (imhtml->bits) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3627 GtkIMHtmlBit *bit = imhtml->bits->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3628 imhtml->bits = g_list_remove (imhtml->bits, bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3629 if (bit->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3630 g_free (bit->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3631 if (bit->font)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3632 gdk_font_unref (bit->font);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3633 if (bit->fore)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3634 gdk_color_free (bit->fore);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3635 if (bit->back)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3636 gdk_color_free (bit->back);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3637 if (bit->bg)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3638 gdk_color_free (bit->bg);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3639 if (bit->url)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3640 g_free (bit->url);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3641 if (bit->pm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3642 gdk_pixmap_unref (bit->pm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3643 if (bit->bm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3644 gdk_bitmap_unref (bit->bm);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3645 #if USE_PIXBUF
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3646 if (bit->img) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3647 g_free(bit->img->filename);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3648 g_free(bit->img->data);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3649 gdk_pixbuf_unref(bit->img->pb);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3650 g_free(bit->img);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3651 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3652 #endif
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3653
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3654 while (bit->chunks) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3655 struct line_info *li = bit->chunks->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3656 if (li->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3657 g_free (li->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3658 bit->chunks = g_list_remove (bit->chunks, li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3659 g_free (li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3660 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3661 g_free (bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3662 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3663
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3664 while (imhtml->click) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3665 g_free (imhtml->click->data);
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3666 imhtml->click = g_list_remove (imhtml->click, imhtml->click->data);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3667 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3668
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3669 #if USE_PIXBUF
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3670 while (imhtml->im_images) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3671 imhtml->im_images = g_list_remove(imhtml->im_images, imhtml->im_images->data);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3672 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3673 #endif
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3674
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3675 if (imhtml->selected_text) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3676 g_string_free (imhtml->selected_text, TRUE);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3677 imhtml->selected_text = g_string_new ("");
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3678 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3679
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3680 imhtml->sel_startx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3681 imhtml->sel_starty = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3682 imhtml->sel_endx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3683 imhtml->sel_endx = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3684 imhtml->sel_endchunk = NULL;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3685
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3686 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3687 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3688 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3689 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3690 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3691 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3692 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3693 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3694 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3695
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3696 if (imhtml->scroll_timer) {
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3697 gtk_timeout_remove (imhtml->scroll_timer);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3698 imhtml->scroll_timer = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3699 }
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3700
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3701 #if USE_PIXBUF
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3702 g_list_free(imhtml->im_images);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3703 imhtml->im_images = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3704 #endif
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2982
diff changeset
3705
1998
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3706 imhtml->x = 0;
00dc6b2df5b6 [gaim-migrate @ 2008]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1997
diff changeset
3707 imhtml->y = TOP_BORDER;
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3708 imhtml->xsize = 0;
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3709 imhtml->llheight = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3710 imhtml->llascent = 0;
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3711 if (imhtml->line)
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3712 g_list_free (imhtml->line);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3713 imhtml->line = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3714
2621
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3715 layout->hadjustment->page_size = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3716 layout->hadjustment->page_increment = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3717 layout->hadjustment->lower = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3718 layout->hadjustment->upper = imhtml->x;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3719 gtk_adjustment_set_value (layout->hadjustment, 0);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3720
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3721 layout->vadjustment->page_size = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3722 layout->vadjustment->page_increment = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3723 layout->vadjustment->lower = 0;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3724 layout->vadjustment->upper = imhtml->y;
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3725 gtk_adjustment_set_value (layout->vadjustment, 0);
f8b02cf4af94 [gaim-migrate @ 2634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2615
diff changeset
3726
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3727 if (GTK_WIDGET_REALIZED (GTK_WIDGET (imhtml))) {
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3728 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor);
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3729 gdk_window_clear (GTK_LAYOUT (imhtml)->bin_window);
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3730 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3731 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2826
diff changeset
3732 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3733 }
2363
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3734
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3735 void
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3736 gtk_imhtml_page_up (GtkIMHtml *imhtml)
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3737 {
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3738 GtkAdjustment *vadj;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3739
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3740 g_return_if_fail (imhtml != NULL);
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3741 g_return_if_fail (GTK_IS_IMHTML (imhtml));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3742
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3743 vadj = GTK_LAYOUT (imhtml)->vadjustment;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3744 gtk_adjustment_set_value (vadj, MAX (vadj->value - vadj->page_increment,
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3745 vadj->lower));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3746 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed");
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3747 }
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3748
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3749 void
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3750 gtk_imhtml_page_down (GtkIMHtml *imhtml)
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3751 {
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3752 GtkAdjustment *vadj;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3753
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3754 g_return_if_fail (imhtml != NULL);
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3755 g_return_if_fail (GTK_IS_IMHTML (imhtml));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3756
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3757 vadj = GTK_LAYOUT (imhtml)->vadjustment;
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3758 gtk_adjustment_set_value (vadj, MIN (vadj->value + vadj->page_increment,
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3759 vadj->upper - vadj->page_size));
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3760 gtk_signal_emit_by_name (GTK_OBJECT (vadj), "changed");
08c66712364c [gaim-migrate @ 2376]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2349
diff changeset
3761 }