annotate src/gtkimhtml.c @ 1930:21f24c30ba1c

[gaim-migrate @ 1940] It finally annoyed me. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 31 May 2001 23:02:03 +0000
parents d7cbedd1d651
children 9ed99b8c5c9c
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #include "gtkimhtml.h"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include <gtk/gtk.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include <string.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include <ctype.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include <stdio.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <math.h>
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "pixmaps/angel.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include "pixmaps/bigsmile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include "pixmaps/burp.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include "pixmaps/crossedlips.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include "pixmaps/cry.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include "pixmaps/embarrassed.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include "pixmaps/kiss.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include "pixmaps/moneymouth.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include "pixmaps/sad.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include "pixmaps/scream.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include "pixmaps/smile.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include "pixmaps/smile8.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #include "pixmaps/think.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #include "pixmaps/tongue.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #include "pixmaps/wink.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include "pixmaps/yell.xpm"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #define DEFAULT_FONT_NAME "helvetica"
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #define MAX_SIZE 7
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 gint font_sizes [] = { 80, 100, 120, 140, 200, 300, 400 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #define BORDER_SIZE 3
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #define MIN_HEIGHT 20
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #define HR_HEIGHT 2
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
54 #define TOOLTIP_TIMEOUT 500
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
56 #define DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
57 #define COLOR_MOD 0x8000
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
58 #define COLOR_DIFF 0x800
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
59
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 #define TYPE_TEXT 0
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 #define TYPE_SMILEY 1
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #define TYPE_IMG 2
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 #define TYPE_SEP 3
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 #define TYPE_BR 4
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 #define TYPE_COMMENT 5
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
67 #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
68
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 typedef struct _GtkIMHtmlBit GtkIMHtmlBit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 typedef struct _FontDetail FontDetail;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 struct _GtkIMHtmlBit {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 gint type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 GdkPixmap *pm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 GdkBitmap *bm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 GdkColor *bg;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 gboolean underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 gboolean strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 gchar *url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 struct _FontDetail {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 gushort size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 gchar *face;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 struct line_info {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 gint height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 gint ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 gboolean selected;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 gchar *sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 gchar *sel_end;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 struct url_widget {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 gint height;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
117 GtkIMHtmlBit *bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 static GtkLayoutClass *parent_class = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 TARGET_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 TARGET_TEXT,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 TARGET_COMPOUND_TEXT
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 LAST_SIGNAL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 static void gtk_imhtml_draw_bit (GtkIMHtml *, GtkIMHtmlBit *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 static GdkColor *gtk_imhtml_get_color (const gchar *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 static gint gtk_imhtml_motion_notify_event (GtkWidget *, GdkEventMotion *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 gtk_imhtml_destroy (GtkObject *object)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 imhtml = GTK_IMHTML (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 while (imhtml->bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 GtkIMHtmlBit *bit = imhtml->bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 imhtml->bits = g_list_remove (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 if (bit->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 g_free (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 if (bit->font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 gdk_font_unref (bit->font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 if (bit->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 gdk_color_free (bit->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 if (bit->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 gdk_color_free (bit->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 if (bit->bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 gdk_color_free (bit->bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 if (bit->url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 g_free (bit->url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 if (bit->pm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 gdk_pixmap_unref (bit->pm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 if (bit->bm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 gdk_bitmap_unref (bit->bm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 while (bit->chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
165 struct line_info *li = bit->chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 if (li->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 g_free (li->text);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
168 bit->chunks = g_list_remove (bit->chunks, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 g_free (li);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 g_free (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 if (imhtml->selected_text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
182 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
183 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
184 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
185 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
186 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
187 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
188 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
189 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
190 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
191
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 gdk_color_free (imhtml->default_fg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
194 gdk_color_free (imhtml->default_bg_color);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 gdk_cursor_destroy (imhtml->hand_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 gdk_cursor_destroy (imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 g_hash_table_destroy (imhtml->smiley_hash);
1519
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
200 if (imhtml->smiley_start)
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
201 g_string_free (imhtml->smiley_start, TRUE);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 gtk_imhtml_realize (GtkWidget *widget)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 if (GTK_WIDGET_CLASS (parent_class)->realize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 widget->style = gtk_style_attach (widget->style, widget->window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
221 gdk_window_set_events (GTK_LAYOUT (imhtml)->bin_window,
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
222 (gdk_window_get_events (GTK_LAYOUT (imhtml)->bin_window)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
224 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
228 gdk_color_alloc (gtk_widget_get_colormap (widget), imhtml->default_bg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
229 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
230 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
231
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
232 static gboolean
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
233 similar_colors (GdkColor *bg,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
234 GdkColor *fg)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
235 {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
236 if ((DIFF (bg->red, fg->red) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
237 (DIFF (bg->green, fg->green) < COLOR_DIFF) &&
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
238 (DIFF (bg->blue, fg->blue) < COLOR_DIFF)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
239 fg->red = (0xff00 - COLOR_MOD > bg->red) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
240 bg->red + COLOR_MOD : bg->red - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
241 fg->green = (0xff00 - COLOR_MOD > bg->green) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
242 bg->green + COLOR_MOD : bg->green - COLOR_MOD;
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
243 fg->blue = (0xff00 - COLOR_MOD > bg->blue) ?
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
244 bg->blue + COLOR_MOD : bg->blue - COLOR_MOD;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
245 return TRUE;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
246 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
247 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
251 draw_text (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
252 struct line_info *line)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
254 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
255 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
256 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
257 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
258 gfloat xoff, yoff;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
259 GdkColor *bg, *fg;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
260
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
261 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
262 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
263
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
264 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
265 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
266 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
267 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
268 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
269
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
270 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
271 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
272 gdk_gc_set_foreground (gc, bit->bg);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
273 bg = bit->bg;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
274 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
275 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
276 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
277 bg = imhtml->default_bg_color;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
278 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
279
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
280 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
281
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
282 if (!line->text) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
283 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
284 return;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
285 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
286
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
287 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
288 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
289 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
290 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
291 gdk_string_width (bit->font, line->text), line->height);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
292 bg = bit->back;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
293 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
294
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
295 bg = gdk_color_copy (bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
296
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
297 if (line->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
298 gint width, x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
299 gchar *start, *end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
300 GdkColor col;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
301
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
302 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
303 start = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
304 end = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
305 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
306 start = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
307 end = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
308 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
309
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
310 if (start == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
311 x = 0;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
312 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
313 x = gdk_text_width (bit->font, line->text, start - line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
314
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
315 if (end == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
316 width = gdk_string_width (bit->font, line->text) - x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
317 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
318 width = gdk_text_width (bit->font, line->text, end - line->text) - x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
319
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
320 col.red = col.green = col.blue = 0xc000;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
321 gdk_color_alloc (cmap, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
322 gdk_gc_set_foreground (gc, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
323
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
324 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
325 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
326 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
327
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
328 if (bit->url) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
329 GdkColor *tc = gtk_imhtml_get_color ("#0000a0");
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
330 gdk_color_alloc (cmap, tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
331 gdk_gc_set_foreground (gc, tc);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
332 fg = gdk_color_copy (tc);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
333 gdk_color_free (tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
334 } else if (bit->fore) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
335 gdk_color_alloc (cmap, bit->fore);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
336 gdk_gc_set_foreground (gc, bit->fore);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
337 fg = gdk_color_copy (bit->fore);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
338 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
339 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
340 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
341 fg = gdk_color_copy (imhtml->default_fg_color);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
342 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
343
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
344 if (similar_colors (bg, fg)) {
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
345 gdk_color_alloc (cmap, fg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
346 gdk_gc_set_foreground (gc, fg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
347 }
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
348 gdk_color_free (bg);
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
349 gdk_color_free (fg);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
350
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
351 gdk_draw_string (window, bit->font, gc, line->x - xoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
352 line->y - yoff + line->ascent, line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
353
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
354 if (bit->underline || bit->url)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
355 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff, line->y - yoff + line->ascent + 1,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
356 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
357 if (bit->strike)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
358 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
359 line->y - yoff + line->ascent - (bit->font->ascent / 2),
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
360 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
361
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
362 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
363 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
364
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
365 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
366 draw_img (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
367 struct line_info *line)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
368 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
369 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
370 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
371 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
372 gint width, height, hoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
373 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
374 gfloat xoff, yoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
375
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
376 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
377 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
378
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
379 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
380 gdk_window_get_size (bit->pm, &width, &height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
381 hoff = (line->height - height) / 2;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
382 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
383 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
384 gc = gdk_gc_new (window);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
385 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
386
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
387 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
388 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
389 gdk_gc_set_foreground (gc, bit->bg);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
390 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
391 gdk_color_alloc (cmap, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
392 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
393 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
394
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
395 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
396
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
397 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
398 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
399 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
400 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
401 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
402 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
403
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
404 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
405
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
406 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
407 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
408
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
409 static void
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
410 draw_line (GtkIMHtml *imhtml,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
411 struct line_info *line)
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
412 {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
413 GtkIMHtmlBit *bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
414 GdkDrawable *drawable;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
415 GdkColormap *cmap;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
416 GdkGC *gc;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
417 guint line_height;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
418 gfloat xoff, yoff;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
419
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
420 if (GTK_LAYOUT (imhtml)->freeze_count)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
421 return;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
422
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
423 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
424 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
425 bit = line->bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
426 drawable = GTK_LAYOUT (imhtml)->bin_window;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
427 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
428 gc = gdk_gc_new (drawable);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
429
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
430 if (bit->bg != NULL) {
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
431 gdk_color_alloc (cmap, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
432 gdk_gc_set_foreground (gc, bit->bg);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
433
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
434 gdk_draw_rectangle (drawable, gc, TRUE, line->x - xoff, line->y - yoff,
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
435 line->width, line->height);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
436 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
437
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
438 gdk_color_alloc (cmap, imhtml->default_fg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
439 gdk_gc_set_foreground (gc, imhtml->default_fg_color);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
440
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
441 line_height = line->height / 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
442
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
443 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
444 line->width, line_height);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
445
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
446 gdk_gc_unref (gc);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
447 }
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
448
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
449 static void
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
450 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
451 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
452 GList *bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
453 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
454 GList *chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
455 struct line_info *line;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
456 gfloat x, y;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
457 guint32 width, height;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
458
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
459 x = GTK_LAYOUT (imhtml)->hadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
460 y = GTK_LAYOUT (imhtml)->vadjustment->value;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
461 width = GTK_WIDGET (imhtml)->allocation.width;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
462 height = GTK_WIDGET (imhtml)->allocation.height;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
463
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
464 bits = imhtml->bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
465
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
466 while (bits) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
467 bit = bits->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
468 chunks = bit->chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
469 if (DRAW_IMG (bit)) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
470 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
471 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
472 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
473 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
474 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
475 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
476 draw_img (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
477 }
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
478 } else if (bit->type == TYPE_SEP) {
1461
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
479 if (chunks) {
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
480 line = chunks->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
481 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
482 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
483 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
484 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
485 draw_line (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
486
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
487 line = chunks->next->data;
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
488 if ((line->x <= x + width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
489 (line->y <= y + height) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
490 (x <= line->x + line->width) &&
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
491 (y <= line->y + line->height))
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
492 draw_text (imhtml, line);
9774a0a304c4 [gaim-migrate @ 1471]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1460
diff changeset
493 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
494 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
495 while (chunks) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
496 line = chunks->data;
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
497 if ((line->x <= x + width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
498 (line->y <= y + height) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
499 (x <= line->x + line->width) &&
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
500 (y <= line->y + line->height))
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
501 draw_text (imhtml, line);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
502 chunks = g_list_next (chunks);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
503 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
504 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
505 bits = g_list_next (bits);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
506 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 gtk_imhtml_draw (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 GdkRectangle *area)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
513 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
514
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
515 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
516 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 gtk_imhtml_style_set (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 GtkStyle *style)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 g_return_if_fail (GTK_IS_IMHTML (widget));
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
527
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
528 if (GTK_WIDGET_CLASS (parent_class)->style_set)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
529 (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, style);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
530
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 if (!GTK_WIDGET_REALIZED (widget))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 imhtml = GTK_IMHTML (widget);
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
535 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 static gint
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
539 gtk_imhtml_expose_event (GtkWidget *widget,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
540 GdkEventExpose *event)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
542 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
543
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
544 g_return_val_if_fail (widget != NULL, FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
545 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
546
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 if (GTK_WIDGET_CLASS (parent_class)->expose_event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
550 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
551 gtk_imhtml_draw_exposed (imhtml);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
552
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
553 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 gtk_imhtml_redraw_all (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 GList *b;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 gfloat oldvalue;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
563 gint oldy;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 oldvalue = vadj->value / vadj->upper;
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
567 oldy = imhtml->y;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
569 gtk_layout_freeze (GTK_LAYOUT (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 imhtml->y = BORDER_SIZE + 10;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584 b = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 while (b) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
586 bit = b->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 b = g_list_next (b);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
588 while (bit->chunks) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
589 struct line_info *li = bit->chunks->data;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
590 if (li->text)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
591 g_free (li->text);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
592 bit->chunks = g_list_remove (bit->chunks, li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
593 g_free (li);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
594 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
595 gtk_imhtml_draw_bit (imhtml, bit);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
598 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y + 5);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599 gtk_adjustment_set_value (vadj, vadj->upper * oldvalue);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
600
1527
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
601 if (GTK_LAYOUT (imhtml)->bin_window && (imhtml->y < oldy)) {
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
602 GdkGC *gc;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
603 GdkColormap *cmap;
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
604
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
605 gc = gdk_gc_new (GTK_LAYOUT (imhtml)->bin_window);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
606 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml));
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
607
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
608 gdk_color_alloc (cmap, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
609 gdk_gc_set_foreground (gc, imhtml->default_bg_color);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
610
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
611 gdk_draw_rectangle (GTK_LAYOUT (imhtml)->bin_window, gc, TRUE,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
612 0, imhtml->y - GTK_LAYOUT (imhtml)->vadjustment->value,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
613 GTK_WIDGET (imhtml)->allocation.width,
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
614 oldy - imhtml->y);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
615
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
616 gdk_gc_unref (gc);
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
617 }
11977dd0fd29 [gaim-migrate @ 1537]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1524
diff changeset
618
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
619 gtk_layout_thaw (GTK_LAYOUT (imhtml));
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 gtk_imhtml_size_allocate (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 GtkAllocation *allocation)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 g_return_if_fail (allocation != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 ( *GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
637 if (allocation->width == imhtml->xsize) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
638 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y + 5 - allocation->height)) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
639 if (imhtml->y + 5 > allocation->height)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
640 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment,
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
641 imhtml->y + 5 - allocation->height);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
642 else
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
643 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, 0);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
644 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 return;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
646 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 imhtml->xsize = allocation->width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 gtk_imhtml_select_none (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
669 chunk = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
670
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
671 if (chunk->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
672 chunk->selected = FALSE;
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
673 chunk->sel_start = chunk->text;
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
674 chunk->sel_end = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
675 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
676 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
677 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
678 draw_line (imhtml, chunk);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
679 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
680 draw_text (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
681 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 }
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
688 imhtml->sel_endchunk = NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 static gchar*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 get_position (struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 gint x,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 gint width = x - chunk->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 gchar *pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699 guint total = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707 if (smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 if (width <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718 return text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720 for (pos = text; *pos != '\0'; pos++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 gint char_width = gdk_text_width (chunk->bit->font, pos, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 if ((width > total) && (width <= total + char_width)) {
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
723 if (width < total + (char_width / 2))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 return ++pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 total += char_width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 static GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 append_to_sel (GString *string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739 GString *new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 gchar *buf;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 gchar *start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 if (smileys) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 start = (chunk->sel_start == NULL) ? chunk->bit->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768 case TYPE_BR:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 buf = g_strdup ("\n");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 new_string = g_string_append (string, buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 g_free (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 return new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 #define COORDS_IN_CHUNK(xx, yy) (((xx) < chunk->x + chunk->width) && \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 ((yy) < chunk->y + chunk->height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 gtk_imhtml_select_bits (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793 guint startx = imhtml->sel_startx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794 starty = imhtml->sel_starty,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795 endx = imhtml->sel_endx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
796 endy = imhtml->sel_endy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797 gchar *new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798 gint selection = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
799 gboolean smileys = imhtml->smileys;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800 gboolean redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801 gboolean got_start = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
802 gboolean got_end = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 if (!imhtml->selection)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 if (imhtml->selected_text) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
816 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 chunks = bit->chunks;
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 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
820 chunk = chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 switch (selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 case 0:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 if (COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 got_start = TRUE;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837 if (COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 if (got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 if (chunk->sel_end != new_pos)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 if (chunk->sel_start > new_pos) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 chunk->sel_end = chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 selection = 2;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
848 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
853 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
854 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
855 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
856 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
860 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
863 } else if (!COORDS_IN_CHUNK (startx, starty) && !got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
864 if (chunk->selected)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
865 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
866 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
868 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
873 if (!got_start && COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
874 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
880 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 } else if (!got_end && COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 selection++;
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
894 imhtml->sel_endchunk = chunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897 if ( !chunk->selected ||
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
898 (chunk->sel_end != NULL) ||
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
899 (chunk->sel_start != chunk->text))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 }
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 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907 case 2:
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
908 if (chunk->selected)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
912 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
913 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
914 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
915
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
916 if (chunk->selected == TRUE)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
917 imhtml->selected_text = append_to_sel (imhtml->selected_text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
918 chunk, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
919
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
920 if (redraw) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
921 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
922 draw_img (imhtml, chunk);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
923 else if ((bit->type == TYPE_SEP) && (bit->chunks->data == chunk))
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
924 draw_line (imhtml, chunk);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
925 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
926 draw_text (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928 }
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 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
931 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
937 static void
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
938 gtk_imhtml_select_in_chunk (GtkIMHtml *imhtml,
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
939 struct line_info *chunk)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
940 {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
941 GtkIMHtmlBit *bit = chunk->bit;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
942 gchar *new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
943 guint endx = imhtml->sel_endx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
944 guint startx = imhtml->sel_startx;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
945 guint starty = imhtml->sel_starty;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
946 gboolean smileys = imhtml->smileys;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
947 gboolean redraw = FALSE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
948
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
949 new_pos = get_position (chunk, endx, smileys);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
950 if ((starty < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
951 ((starty < chunk->y + chunk->height) && (startx < endx))) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
952 if (chunk->sel_end != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
953 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
954 chunk->sel_end = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
955 } else {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
956 if (chunk->sel_start != new_pos)
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
957 redraw = TRUE;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
958 chunk->sel_start = new_pos;
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
959 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
960
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
961 if (redraw) {
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
962 if (DRAW_IMG (bit))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
963 draw_img (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
964 else if ((bit->type == TYPE_SEP) &&
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
965 (bit->chunks->data == chunk))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
966 draw_line (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
967 else
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
968 draw_text (imhtml, chunk);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
969 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
970 }
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
971
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 scroll_timeout (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 GdkEventMotion event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 GdkModifierType mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
981 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
982
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 if (mask & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 event.is_hint = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 event.x = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986 event.y = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 event.state = mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989 gtk_imhtml_motion_notify_event (GTK_WIDGET (imhtml), &event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 static gint
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
996 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
997 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
998 GtkStyle *style;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
999 gint y, baseline_skip, gap;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1000
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1001 style = imhtml->tip_window->style;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1002
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1003 gap = (style->font->ascent + style->font->descent) / 4;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1004 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1005 gap = 2;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1006 baseline_skip = style->font->ascent + style->font->descent + gap;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1007
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1008 if (!imhtml->tip_bit)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1009 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1010
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1011 gtk_paint_flat_box(style, imhtml->tip_window->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1012 NULL, imhtml->tip_window, "tooltip", 0, 0, -1, -1);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1013
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1014 y = style->font->ascent + 4;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1015 gtk_paint_string (style, imhtml->tip_window->window, GTK_STATE_NORMAL, NULL,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1016 imhtml->tip_window, "tooltip", 4, y, imhtml->tip_bit->url);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1017
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1018 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1019 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1020
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1021 static gint
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1022 gtk_imhtml_tip (gpointer data)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1023 {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1024 GtkIMHtml *imhtml = data;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1025 GtkWidget *widget = GTK_WIDGET (imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1026 GtkStyle *style;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1027 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
1028
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1029 if (!imhtml->tip_bit || !GTK_WIDGET_DRAWABLE (widget)) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1030 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1031 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1032 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1033
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1034 if (imhtml->tip_window)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1035 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1036
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1037 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1038 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1039 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
1040 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips");
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1041 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "expose_event",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1042 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1043 gtk_signal_connect_object (GTK_OBJECT (imhtml->tip_window), "draw",
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1044 GTK_SIGNAL_FUNC (gtk_imhtml_tip_paint), GTK_OBJECT (imhtml));
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1045
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1046 gtk_widget_ensure_style (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1047 style = imhtml->tip_window->style;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1048
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1049 scr_w = gdk_screen_width ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1050 scr_h = gdk_screen_height ();
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1051
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1052 gap = (style->font->ascent + style->font->descent) / 4;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1053 if (gap < 2)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1054 gap = 2;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1055 baseline_skip = style->font->ascent + style->font->descent + gap;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1056
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1057 w = 8 + gdk_string_width (style->font, imhtml->tip_bit->url);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1058 h = 8 - gap + baseline_skip;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1059
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1060 gdk_window_get_pointer (NULL, &x, &y, NULL);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1061 if (GTK_WIDGET_NO_WINDOW (widget))
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1062 y += widget->allocation.y;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1063
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1064 x -= ((w >> 1) + 4);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1065
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1066 if ((x + w) > scr_w)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1067 x -= (x + w) - scr_w;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1068 else if (x < 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1069 x = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1070
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1071 if ((y + h + + 4) > scr_h)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1072 y = y - imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1073 else
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1074 y = y + imhtml->tip_bit->font->ascent + imhtml->tip_bit->font->descent;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1075
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1076 gtk_widget_set_usize (imhtml->tip_window, w, h);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1077 gtk_widget_popup (imhtml->tip_window, x, y);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1078
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1079 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1080 return FALSE;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1081 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1082
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1083 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 gtk_imhtml_motion_notify_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 GdkEventMotion *event)
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 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 GdkModifierType state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 if (event->is_hint)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 gdk_window_get_pointer (event->window, &x, &y, &state);
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 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 state = event->state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1100
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1101 if (state & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 gint height = vadj->page_size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104 gint yy = y - vadj->value;
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 if (((yy < 0) || (yy > height)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 (imhtml->scroll_timer == 0) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 (vadj->upper > vadj->page_size)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 imhtml->scroll_timer = gtk_timeout_add (100,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 (GtkFunction) scroll_timeout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 imhtml);
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1112 diff = (yy < 0) ? (yy / 2) : ((yy - height) / 2);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1113 gtk_adjustment_set_value (vadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 MIN (vadj->value + diff, vadj->upper - height + 20));
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 if (imhtml->selection) {
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1118 struct line_info *chunk = imhtml->sel_endchunk;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 imhtml->sel_endy = MAX (y, 0);
1515
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1121 if ((chunk == NULL) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1122 (x < chunk->x) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1123 (x > chunk->x + chunk->width) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1124 (y < chunk->y) ||
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1125 (y > chunk->y + chunk->height))
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1126 gtk_imhtml_select_bits (imhtml);
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1127 else
206f995a33f3 [gaim-migrate @ 1525]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1482
diff changeset
1128 gtk_imhtml_select_in_chunk (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 GList *urls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1133
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134 while (urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 uw = (struct url_widget *) urls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 if ((x > uw->x) && (x < uw->x + uw->width) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1138 if (imhtml->tip_bit != uw->bit) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1139 imhtml->tip_bit = uw->bit;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1140 if (imhtml->tip_timer != 0)
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1141 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1142 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1143 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1144 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1145 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1146 imhtml->tip_timer = gtk_timeout_add (TOOLTIP_TIMEOUT,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1147 gtk_imhtml_tip,
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1148 imhtml);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1149 }
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1150 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window,
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1151 imhtml->hand_cursor);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 urls = g_list_next (urls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1158 if (imhtml->tip_timer) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1159 gtk_timeout_remove (imhtml->tip_timer);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1160 imhtml->tip_timer = 0;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1161 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1162 if (imhtml->tip_window) {
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1163 gtk_widget_destroy (imhtml->tip_window);
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1164 imhtml->tip_window = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1165 }
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1166 imhtml->tip_bit = NULL;
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1167
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1168 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
1169
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 static gint
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1174 gtk_imhtml_leave_notify_event (GtkWidget *widget,
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1175 GdkEventCrossing *event)
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1176 {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1177 GtkIMHtml *imhtml = GTK_IMHTML (widget);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1178
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1179 if (imhtml->tip_timer) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1180 gtk_timeout_remove (imhtml->tip_timer);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1181 imhtml->tip_timer = 0;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1182 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1183 if (imhtml->tip_window) {
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1184 gtk_widget_destroy (imhtml->tip_window);
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1185 imhtml->tip_window = NULL;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1186 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1187 imhtml->tip_bit = NULL;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1188
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1189 return TRUE;
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1190 }
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1191
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1192 static gint
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 gtk_imhtml_button_press_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 if (event->button == 1) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 imhtml->sel_startx = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 imhtml->sel_starty = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 imhtml->selection = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 gtk_imhtml_select_none (imhtml);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 gtk_imhtml_button_release_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222
1456
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1223 x = event->x + hadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1224 y = event->y + vadj->value;
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1454
diff changeset
1225
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 if ((event->button == 1) && imhtml->selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227 if ((x == imhtml->sel_startx) && (y == imhtml->sel_starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 imhtml->sel_startx = imhtml->sel_starty = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229 imhtml->selection = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 imhtml->sel_endy = MAX (y, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 gtk_imhtml_select_bits (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237 gtk_selection_owner_set (widget, GDK_SELECTION_PRIMARY, event->time);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239
1547
7b50a08090a2 [gaim-migrate @ 1557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1528
diff changeset
1240 if ((event->button == 1) && (imhtml->sel_startx == 0)) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1241 GList *urls = imhtml->urls;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1242 struct url_widget *uw;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1243
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1244 while (urls) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1245 uw = (struct url_widget *) urls->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1246 if ((x > uw->x) && (x < uw->x + uw->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1247 (y > uw->y) && (y < uw->y + uw->height)) {
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1248 gtk_signal_emit (GTK_OBJECT (imhtml), signals [URL_CLICKED],
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1249 uw->bit->url);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1250 return TRUE;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1251 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1252 urls = g_list_next (urls);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1253 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1254 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1255
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260 gtk_imhtml_selection_get (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261 GtkSelectionData *sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262 guint sel_info,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1263 guint32 time)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1264 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266 gchar *string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1268
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 g_return_if_fail (sel_data->selection == GDK_SELECTION_PRIMARY);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1275 g_return_if_fail (imhtml->selected_text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 g_return_if_fail (imhtml->selected_text->str != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1278 if (imhtml->selected_text->len <= 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 string = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280 length = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282 string = g_strdup (imhtml->selected_text->str);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 length = strlen (string);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1285
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286 if (sel_info == TARGET_STRING) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287 gtk_selection_data_set (sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288 GDK_SELECTION_TYPE_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1289 8 * sizeof (gchar),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290 (guchar *) string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291 length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 } else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293 guchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 GdkAtom encoding;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 gint format;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296 gint new_length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 gdk_string_to_compound_text (string, &encoding, &format, &text, &new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 gtk_selection_data_set (sel_data, encoding, format, text, new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300 gdk_free_compound_text (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303 if (string)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1304 g_free (string);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1307 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308 gtk_imhtml_selection_clear_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 GdkEventSelection *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313 g_return_val_if_fail (widget != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 g_return_val_if_fail (event != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1316 g_return_val_if_fail (event->selection == GDK_SELECTION_PRIMARY, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1317
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 if (!gtk_selection_clear (widget, event))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326 }
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1329 gtk_imhtml_set_scroll_adjustments (GtkLayout *layout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1330 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1331 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1332 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1333 if (parent_class->set_scroll_adjustments)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1334 (* parent_class->set_scroll_adjustments) (layout, hadj, vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1335 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1336
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1337 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1338 gtk_imhtml_class_init (GtkIMHtmlClass *class)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 GtkObjectClass *object_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341 GtkWidgetClass *widget_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342 GtkLayoutClass *layout_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1343
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1344 object_class = (GtkObjectClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 widget_class = (GtkWidgetClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1346 layout_class = (GtkLayoutClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1348 parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1349
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1350 signals [URL_CLICKED] =
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 gtk_signal_new ("url_clicked",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352 GTK_RUN_FIRST,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353 object_class->type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354 GTK_SIGNAL_OFFSET (GtkIMHtmlClass, url_clicked),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1355 gtk_marshal_NONE__POINTER,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1356 GTK_TYPE_NONE, 1,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1357 GTK_TYPE_POINTER);
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 gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1361 object_class->destroy = gtk_imhtml_destroy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1362
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1363 widget_class->realize = gtk_imhtml_realize;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1364 widget_class->draw = gtk_imhtml_draw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1365 widget_class->style_set = gtk_imhtml_style_set;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1366 widget_class->expose_event = gtk_imhtml_expose_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367 widget_class->size_allocate = gtk_imhtml_size_allocate;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1368 widget_class->motion_notify_event = gtk_imhtml_motion_notify_event;
1613
35a13ece3a9c [gaim-migrate @ 1623]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1582
diff changeset
1369 widget_class->leave_notify_event = gtk_imhtml_leave_notify_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1370 widget_class->button_press_event = gtk_imhtml_button_press_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1371 widget_class->button_release_event = gtk_imhtml_button_release_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1372 widget_class->selection_get = gtk_imhtml_selection_get;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1373 widget_class->selection_clear_event = gtk_imhtml_selection_clear_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1374
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1375 layout_class->set_scroll_adjustments = gtk_imhtml_set_scroll_adjustments;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1376 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1377
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1378 static GdkFont*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1379 gtk_imhtml_font_load (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1380 gchar *name,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1381 gboolean bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1382 gboolean italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1383 gint fontsize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1384 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1385 gchar buf [16 * 1024];
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1387 gint size = fontsize ? font_sizes [MIN (fontsize, MAX_SIZE) - 1] : 120;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1388
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1389 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1390 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1391 bold ? "bold" : "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1392 italics ? 'i' : 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1394 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1395 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1396 return font;
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 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 bold ? "bold" : "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 'o',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1404 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1405 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411 "bold",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416 return font;
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 italics ? 'i' : 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1427 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433 "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434 'o',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1438 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1441
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1442 if (!bold && !italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 g_snprintf (buf, sizeof (buf), "-*-%s-medium-r-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 g_snprintf (buf, sizeof (buf), "-*-%s-medium-r-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452 DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1455 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459 return gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1460
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1462 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1463
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1464 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 gtk_imhtml_init (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467 static const GtkTargetEntry targets [] = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 { "STRING", 0, TARGET_STRING },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 { "TEXT", 0, TARGET_TEXT },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473 imhtml->default_font = gtk_imhtml_font_load (imhtml, NULL, FALSE, FALSE, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1474 if (imhtml->default_font == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1475 g_warning ("GtkIMHtml: Could not load default font!");
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1476 imhtml->default_fg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
1477 imhtml->default_bg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1478 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1481 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1482 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485 GtkType
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1486 gtk_imhtml_get_type (void)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1487 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1488 static GtkType imhtml_type = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1490 if (!imhtml_type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491 static const GtkTypeInfo imhtml_info = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1492 "GtkIMHtml",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1493 sizeof (GtkIMHtml),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1494 sizeof (GtkIMHtmlClass),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1495 (GtkClassInitFunc) gtk_imhtml_class_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1496 (GtkObjectInitFunc) gtk_imhtml_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1497 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1498 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1499 NULL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1500 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1501
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1502 imhtml_type = gtk_type_unique (GTK_TYPE_LAYOUT, &imhtml_info);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1504
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1505 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1506 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1507
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1508 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1509 gtk_imhtml_init_smiley_hash (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1510 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1511 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1512 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1513
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1514 imhtml->smiley_hash = g_hash_table_new (g_str_hash, g_str_equal);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1515
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1516 gtk_imhtml_associate_smiley (imhtml, ":)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1517 gtk_imhtml_associate_smiley (imhtml, ":-)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1518
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1519 gtk_imhtml_associate_smiley (imhtml, ":(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1520 gtk_imhtml_associate_smiley (imhtml, ":-(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1521
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1522 gtk_imhtml_associate_smiley (imhtml, ";)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1523 gtk_imhtml_associate_smiley (imhtml, ";-)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1524
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525 gtk_imhtml_associate_smiley (imhtml, ":-p", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526 gtk_imhtml_associate_smiley (imhtml, ":-P", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1527
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528 gtk_imhtml_associate_smiley (imhtml, "=-O", scream_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529 gtk_imhtml_associate_smiley (imhtml, ":-*", kiss_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1530 gtk_imhtml_associate_smiley (imhtml, ">:o", yell_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1531 gtk_imhtml_associate_smiley (imhtml, "8-)", smile8_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 gtk_imhtml_associate_smiley (imhtml, ":-$", moneymouth_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533 gtk_imhtml_associate_smiley (imhtml, ":-!", burp_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1534 gtk_imhtml_associate_smiley (imhtml, ":-[", embarrassed_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1535 gtk_imhtml_associate_smiley (imhtml, ":'(", cry_xpm);
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 gtk_imhtml_associate_smiley (imhtml, ":-/", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1538 gtk_imhtml_associate_smiley (imhtml, ":-\\", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1539
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540 gtk_imhtml_associate_smiley (imhtml, ":-X", crossedlips_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 gtk_imhtml_associate_smiley (imhtml, ":-D", bigsmile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542 gtk_imhtml_associate_smiley (imhtml, "O:-)", angel_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 GtkWidget*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 gtk_imhtml_new (GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 GtkIMHtml *imhtml = gtk_type_new (GTK_TYPE_IMHTML);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1550
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 gtk_imhtml_set_adjustments (imhtml, hadj, vadj);
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 imhtml->bits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1554 imhtml->urls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1556 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1557 imhtml->y = BORDER_SIZE + 10;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1558 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1559 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1560 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1561
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1562 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1563 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1564
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1565 imhtml->img = NULL;
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 imhtml->smileys = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1568 imhtml->comments = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1569
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1570 imhtml->smin = G_MAXINT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1571 imhtml->smax = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1572 gtk_imhtml_init_smiley_hash (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1574 return GTK_WIDGET (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1575 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1576
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1577 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1578 gtk_imhtml_set_adjustments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1579 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1580 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1581 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1582 gtk_layout_set_hadjustment (GTK_LAYOUT (imhtml), hadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1583 gtk_layout_set_vadjustment (GTK_LAYOUT (imhtml), vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1584 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1585
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1586 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1587 gtk_imhtml_set_defaults (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1588 GdkFont *font,
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1589 GdkColor *fg_color,
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1590 GdkColor *bg_color)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1591 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1592 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1593 g_return_if_fail (GTK_IS_IMHTML (imhtml));
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 if (font) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1597 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 imhtml->default_font = gdk_font_ref (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1599 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1600
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 if (fg_color) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602 if (imhtml->default_fg_color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1603 gdk_color_free (imhtml->default_fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604 imhtml->default_fg_color = gdk_color_copy (fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605 }
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1606
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1607 if (bg_color) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1608 if (imhtml->default_bg_color)
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1609 gdk_color_free (imhtml->default_bg_color);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
1610 imhtml->default_bg_color = gdk_color_copy (bg_color);
1647
23b734cf1161 [gaim-migrate @ 1657]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1626
diff changeset
1611 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
1612 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1613 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1614
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 gtk_imhtml_set_img_handler (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 GtkIMHtmlImage handler)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622 imhtml->img = handler;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1624
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1625 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1626 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1627 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628 gchar **xpm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1629 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1630 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1631 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1632 g_return_if_fail (text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1633
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1634 if (strlen (text) < imhtml->smin)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1635 imhtml->smin = strlen (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1636
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1637 if (strlen (text) > imhtml->smax)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1638 imhtml->smax = strlen (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1639
1519
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1640 if (!imhtml->smiley_start)
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1641 imhtml->smiley_start = g_string_new ("");
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1642
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1643 if (!strchr (imhtml->smiley_start->str, text [0]))
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1644 imhtml->smiley_start = g_string_append_c (imhtml->smiley_start, text [0]);
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1645
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1646 if (xpm == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1647 g_hash_table_remove (imhtml->smiley_hash, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1648 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1649 g_hash_table_insert (imhtml->smiley_hash, text, xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1650 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1651
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1652 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1653 new_line (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1654 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1655 GList *last = g_list_last (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1656 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1657
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1658 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1659 li = last->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1660 if (li->x + li->width != imhtml->xsize - BORDER_SIZE)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1661 li->width = imhtml->xsize - BORDER_SIZE - li->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1662 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1663
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1664 last = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1665 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1666 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1667 if (li->height < MIN_HEIGHT) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1668 while (last) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1669 gint diff;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1670 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1671 diff = MIN_HEIGHT - li->height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1672 li->height = MIN_HEIGHT;
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1673 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674 last = g_list_next (last);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1675 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1676 imhtml->llheight = MIN_HEIGHT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1677 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1678 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1679
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1680 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1681 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1682
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1683 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1684 imhtml->y += imhtml->llheight;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1685 imhtml->llheight = 0;
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1686 imhtml->llascent = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1687 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690 backwards_update (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1691 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692 gint height,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 gint ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1695 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 GList *ls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1700 if (height > imhtml->llheight) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701 diff = height - imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1703 ls = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1704 while (ls) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1705 li = ls->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1706 li->height += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1707 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1708 li->ascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1710 li->ascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1711 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714 ls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1715 while (ls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1716 uw = ls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1717 if (uw->y + diff > imhtml->y)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718 uw->y += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1721
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1722 imhtml->llheight = height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 imhtml->llascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1725 else
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
1726 imhtml->llascent += diff / 2;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1727 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1728 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1729
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1730 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1731 add_text_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733 gchar *text)
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 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1736 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1737 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1738
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1739 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1740 width = gdk_string_width (bit->font, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1741 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1742 width = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1743
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1744 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1745 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1746 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1747 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1748 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1749 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750 li->ascent = MAX (imhtml->llascent, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1751 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1752 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 li->text = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1754 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1755
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1756 if (bit->url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1757 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1758 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1759 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1760 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1761 uw->height = imhtml->llheight;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1762 uw->bit = bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1763 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1764 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1765
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1766 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1767 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1768 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1769
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1770 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1771 add_img_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1772 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1773 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1774 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1775 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1776 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1777
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1778 gdk_window_get_size (bit->pm, &width, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1779
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1780 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1781 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1782 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1783 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1784 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1785 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1786 li->bit = bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1787
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1788 if (bit->url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1789 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1790 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1791 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1792 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1793 uw->height = imhtml->llheight;
1574
7ad82fa9e6ce [gaim-migrate @ 1584]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1547
diff changeset
1794 uw->bit = bit;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1795 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1796 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1797
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1798 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1799 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1800
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1801 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 gtk_imhtml_draw_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1806 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1807 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 gint width, height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1810 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1812 g_return_if_fail (bit != NULL);
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 if ( (bit->type == TYPE_TEXT) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 ((bit->type == TYPE_SMILEY) && !imhtml->smileys) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1816 ((bit->type == TYPE_COMMENT) && imhtml->comments)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1817 gchar *copy = g_strdup (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1818 gint pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1819 gboolean seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1820 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1821
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822 height = bit->font->ascent + bit->font->descent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1823 width = gdk_string_width (bit->font, bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1824
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1825 if ((imhtml->x != BORDER_SIZE) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1826 ((imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5) > imhtml->xsize)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1827 gint remain = imhtml->xsize - imhtml->x - BORDER_SIZE - BORDER_SIZE - 5;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1828 while (gdk_text_width (bit->font, copy, pos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1829 if (copy [pos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1830 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1831 pos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1832 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 if (seenspace) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834 while (copy [pos - 1] != ' ') pos--;
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 tmp = g_strndup (copy, pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1837
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1838 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1839 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1841 pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1842 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1843 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1844 }
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 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1847
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1848 while (pos < strlen (bit->text)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1849 width = gdk_string_width (bit->font, copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1850 if (imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5 > imhtml->xsize) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1851 gint newpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1852 gint remain = imhtml->xsize - imhtml->x - BORDER_SIZE - BORDER_SIZE - 5;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1853 while (gdk_text_width (bit->font, copy + pos, newpos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1854 if (copy [pos + newpos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1855 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1856 newpos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1857 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1858
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1859 if (seenspace)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1860 while (copy [pos + newpos - 1] != ' ') newpos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1861
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1862 if (newpos == 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1863 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1864
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1865 tmp = g_strndup (copy + pos, newpos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1866 pos += newpos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1867
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1868 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1869 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1870
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1871 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1874 tmp = g_strdup (copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1875
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1876 backwards_update (imhtml, bit, height, bit->font->ascent);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1877 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1878
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1879 pos = strlen (bit->text);
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 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1882 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1883 }
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 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1886 } else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1887 gdk_window_get_size (bit->pm, &width, &height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1888
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1889 if ((imhtml->x != BORDER_SIZE) &&
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1890 ((imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5) > imhtml->xsize))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1891 new_line (imhtml);
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1892 else
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1893 backwards_update (imhtml, bit, height, 0);
1428
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 add_img_renderer (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1896 } else if (bit->type == TYPE_BR) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1898 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1899 } else if (bit->type == TYPE_SEP) {
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1900 struct line_info *li;
1462
1ac49082e099 [gaim-migrate @ 1472]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1461
diff changeset
1901 if (imhtml->llheight)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1902 new_line (imhtml);
1454
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1903
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1904 li = g_new0 (struct line_info, 1);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1905 li->x = imhtml->x;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1906 li->y = imhtml->y;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1907 li->width = imhtml->xsize - BORDER_SIZE - BORDER_SIZE;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1908 li->height = HR_HEIGHT * 2;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1909 li->ascent = 0;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1910 li->text = NULL;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1911 li->bit = bit;
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1912
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1913 bit->chunks = g_list_append (bit->chunks, li);
637592eb8b24 [gaim-migrate @ 1464]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1453
diff changeset
1914
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1915 imhtml->llheight = HR_HEIGHT * 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1916 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1917 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1918 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1919
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1920 gtk_layout_set_size (GTK_LAYOUT (imhtml), imhtml->xsize, imhtml->y + 5);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1921 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1922
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1923 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1924 gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1925 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1926 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1927 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1928 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1929
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1930 imhtml->smileys = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1931
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1932 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1933 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1934 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1935
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1936 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1937 gtk_imhtml_show_comments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1938 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1939 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1940 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1941 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1942
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1943 imhtml->comments = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1944
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1945 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1946 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1947 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949 static GdkColor *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1950 gtk_imhtml_get_color (const gchar *color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1951 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1952 GdkColor c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1953
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
1954 if (!gdk_color_parse (color, &c))
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
1955 return NULL;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1956
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1957 return gdk_color_copy (&c);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1958 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1959
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1960 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1961 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1962 const gchar *text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1964 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1965 gint i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1967 g_return_val_if_fail (imhtml != NULL, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969 g_return_val_if_fail (text != NULL, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970
1519
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1971 if (!imhtml->smiley_start || !strchr (imhtml->smiley_start->str, text [0]))
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1972 return 0;
d3ff7d80b8fb [gaim-migrate @ 1529]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1515
diff changeset
1973
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974 tmp = g_malloc (imhtml->smax + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976 for (i = imhtml->smin; i <= imhtml->smax; i++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1977 if (strlen (text) < i) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979 return 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 g_snprintf (tmp, i + 1, "%s", text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 if (g_hash_table_lookup (imhtml->smiley_hash, tmp)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1984 return i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1985 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1986 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1987
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1988 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1989 return 0;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992 static GtkIMHtmlBit *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1993 gtk_imhtml_new_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 gint type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1995 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1996 gint bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1997 gint italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1998 gint underline,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1999 gint strike,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2000 FontDetail *font,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001 GdkColor *bg,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2002 gchar *url,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2003 gint pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2004 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2005 GtkIMHtmlBit *bit = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
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 if ((type == TYPE_TEXT) && ((text == NULL) || (strlen (text) == 0)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2011 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2013 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2014 bit->type = type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2016 if ((text != NULL) && (strlen (text) != 0))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2017 bit->text = g_strdup (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2019 if ((font != NULL) || bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2020 if (font && (bold || italics || font->size || font->face || pre)) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2021 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2022 bit->font = gtk_imhtml_font_load (imhtml, "courier", bold, italics, font->size);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2023 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2024 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
2025 }
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2026 } else if (bold || italics || pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2027 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2028 bit->font = gtk_imhtml_font_load (imhtml, "Courier", bold, italics, 0);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2029 } else {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2030 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2031 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2032 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2033
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2034 if (font && (type != TYPE_BR)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2035 if (font->fore != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2036 bit->fore = gdk_color_copy (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2037
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2038 if (font->back != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2039 bit->back = gdk_color_copy (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2040 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2041 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2042
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2043 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
2044 (bit->font == NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2045 bit->font = gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2046
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2047 if (bg != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2048 bit->bg = gdk_color_copy (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2049
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2050 bit->underline = underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2051 bit->strike = strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2052
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2053 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2054 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2055
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2056 if (type == TYPE_SMILEY) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2057 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059 if ((font != NULL) && (font->back != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060 clr = font->back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2061 else
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2062 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2064 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2065 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2066 clr,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2067 g_hash_table_lookup (imhtml->smiley_hash, text));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2068 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2069
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2070 return bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2071 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2072
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2073 #define NEW_TEXT_BIT gtk_imhtml_new_bit (imhtml, TYPE_TEXT, ws, bold, italics, underline, strike, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2074 fonts ? fonts->data : NULL, bg, url, pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2075 #define NEW_SMILEY_BIT gtk_imhtml_new_bit (imhtml, TYPE_SMILEY, ws, bold, italics, underline, strike, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2076 fonts ? fonts->data : NULL, bg, url, pre)
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2077 #define NEW_SEP_BIT gtk_imhtml_new_bit (imhtml, TYPE_SEP, NULL, 0, 0, 0, 0, NULL, bg, NULL, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2078 #define NEW_BR_BIT gtk_imhtml_new_bit (imhtml, TYPE_BR, NULL, 0, 0, 0, 0, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2079 fonts ? fonts->data : NULL, bg, NULL, 0)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2080 #define NEW_COMMENT_BIT gtk_imhtml_new_bit (imhtml, TYPE_COMMENT, ws, bold, italics, underline, strike, \
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2081 fonts ? fonts->data : NULL, bg, url, pre)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2082
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2083 #define NEW_BIT(bit) { GtkIMHtmlBit *tmp = bit; if (tmp != NULL) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2084 newbits = g_list_append (newbits, tmp); }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2085
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2086 #define UPDATE_BG_COLORS \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2087 { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2088 GdkColormap *cmap; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2089 GList *rev; \
1476
721cd9b73704 [gaim-migrate @ 1486]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1473
diff changeset
2090 cmap = gtk_widget_get_colormap (GTK_WIDGET (imhtml)); \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2091 rev = g_list_last (newbits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2092 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2093 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2094 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2095 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2096 bit->bg = gdk_color_copy (bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2097 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2098 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2099 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2100 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2101 if (!rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2102 rev = g_list_last (imhtml->bits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2103 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2104 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2105 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2106 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2107 bit->bg = gdk_color_copy (bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2108 gdk_color_alloc (cmap, bit->bg); \
1582
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2109 if (bit->type == TYPE_BR) \
4fcd012c0a6a [gaim-migrate @ 1592]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1574
diff changeset
2110 break; \
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2111 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2112 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2113 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2114 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2115
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2116 static gboolean
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2117 is_amp_escape (const gchar *string,
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2118 gchar *replace,
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2119 gint *length)
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2120 {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2121 g_return_val_if_fail (string != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2122 g_return_val_if_fail (replace != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2123 g_return_val_if_fail (length != NULL, FALSE);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2124
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2125 if (!g_strncasecmp (string, "&amp;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2126 *replace = '&';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2127 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2128 } else if (!g_strncasecmp (string, "&lt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2129 *replace = '<';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2130 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2131 } else if (!g_strncasecmp (string, "&gt;", 4)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2132 *replace = '>';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2133 *length = 4;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2134 } else if (!g_strncasecmp (string, "&nbsp;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2135 *replace = ' ';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2136 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2137 } else if (!g_strncasecmp (string, "&copy;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2138 *replace = '©';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2139 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2140 } else if (!g_strncasecmp (string, "&quot;", 6)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2141 *replace = '\"';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2142 *length = 6;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2143 } else if (!g_strncasecmp (string, "&reg;", 5)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2144 *replace = '®';
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2145 *length = 5;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2146 } else if (*(string + 1) == '#') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2147 gint pound = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2148 if (sscanf (string, "&#%d;", &pound) == 1) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2149 if (*(string + 3 + (gint)log10 (pound)) != ';')
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2150 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2151 *replace = (gchar)pound;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2152 *length = 2;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2153 while (isdigit ((gint) string [*length])) (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2154 if (string [*length] == ';') (*length)++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2155 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2156 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2157 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2158 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2159 return FALSE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2160 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2161
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2162 return TRUE;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2163 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2164
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2165 GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2166 gtk_imhtml_append_text (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2167 const gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2168 GtkIMHtmlOptions options)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2169 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170 const gchar *c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2171 gboolean intag = FALSE;
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2172 gint tagquote = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2173 gboolean incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2174 gchar *ws;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2175 gchar *tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2176 gint wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2177 gint tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2178 int smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2179 GList *newbits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2180
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2181 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2182 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2183 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2184 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2185 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2186 sup = 0,
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2187 title = 0,
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2188 pre = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2189 GSList *fonts = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2190 GdkColor *bg = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2191 gchar *url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2192
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2193 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2194 gboolean scrolldown = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2195
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2196 GString *retval = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2197
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2198 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2199 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2200 g_return_val_if_fail (text != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2201
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2202 if (options & GTK_IMHTML_RETURN_LOG)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2203 retval = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2204
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2205 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2206 if ((vadj->value < imhtml->y + 5 - GTK_WIDGET (imhtml)->allocation.height) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207 (vadj->upper >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 scrolldown = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2209
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 c = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2211 ws = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2212 tag = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2213
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2214 ws [0] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2215
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2216 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2217 if (*c == '<') {
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2218 if (intag && (tagquote != 1)) {
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2219 char *d;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 tag [tpos] = 0;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2221 d = tag;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2222 while (*d) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2223 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2224 ws [wpos] = 0;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2225 wpos = 0;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2226 NEW_BIT (NEW_TEXT_BIT);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2227 g_snprintf (ws, smilelen + 1, "%s", d);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2228 NEW_BIT (NEW_SMILEY_BIT);
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2229 d += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2230 } else if (*d == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2231 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2232 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2233 if (is_amp_escape (d, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2234 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2235 d += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2236 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2237 ws [wpos++] = *d++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2238 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2239 } else if (*d == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2240 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2241 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2242 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2243 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2244 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2245 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2246 d++;
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2247 } else {
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2248 ws [wpos++] = *d++;
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2249 }
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2250 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2254 if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2255 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256 continue;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 if (!g_strncasecmp (c, "<!--", strlen ("<!--"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260 if (!(options & GTK_IMHTML_NO_COMMENTS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2262 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2263 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2264 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2265 incomment = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2267 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2268 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2269 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2270 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2271 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 }
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 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 intag = TRUE;
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2277 tagquote = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2278 } else if (incomment && (*c == '-') && !g_strncasecmp (c, "-->", strlen ("-->"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282 tmp = g_strdup (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2283 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2284 strcat (ws, tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2287 strcat (ws, tmp + strlen ("<!--"));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289 NEW_BIT (NEW_COMMENT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290 incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 c += strlen ("-->");
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2292 } else if (*c == '>' && intag && (tagquote != 1)) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 gboolean got_tag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 ws [wpos] = 0;
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 if (!g_strcasecmp (tag, "<B>") || !g_strcasecmp (tag, "<BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 bold++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 } else if (!g_strcasecmp (tag, "</B>") || !g_strcasecmp (tag, "</BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2304 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308 } else if (!g_strcasecmp (tag, "<I>") || !g_strcasecmp (tag, "<ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 italics++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2312 } else if (!g_strcasecmp (tag, "</I>") || !g_strcasecmp (tag, "</ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2314 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316 italics--;
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 } else if (!g_strcasecmp (tag, "<U>") || !g_strcasecmp (tag, "<UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321 underline++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322 } else if (!g_strcasecmp (tag, "</U>") || !g_strcasecmp (tag, "</UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2324 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 if (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 underline--;
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 } else if (!g_strcasecmp (tag, "<S>") || !g_strcasecmp (tag, "<STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2329 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2330 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2331 strike++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2332 } else if (!g_strcasecmp (tag, "</S>") || !g_strcasecmp (tag, "</STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2334 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335 if (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2336 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338 } else if (!g_strcasecmp (tag, "<SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2340 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 sub++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342 } else if (!g_strcasecmp (tag, "</SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2343 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2344 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2345 if (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2346 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2348 } else if (!g_strcasecmp (tag, "<SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2350 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 sup++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2352 } else if (!g_strcasecmp (tag, "</SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2354 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2355 if (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2358 } else if (!g_strcasecmp (tag, "<PRE>")) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2359 got_tag = TRUE;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2360 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2361 pre++;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2362 } else if (!g_strcasecmp (tag, "</PRE>")) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2363 got_tag = TRUE;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2364 NEW_BIT (NEW_TEXT_BIT);
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2365 if (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2366 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2367 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368 } else if (!g_strcasecmp (tag, "<TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 if (options & GTK_IMHTML_NO_TITLE) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 got_tag = TRUE;
1626
59c7e7831ccd [gaim-migrate @ 1636]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1613
diff changeset
2371 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 title++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2373 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376 continue;
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 } else if (!g_strcasecmp (tag, "</TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 if (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 ws [wpos] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2383 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2388 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2389 } else if (!g_strcasecmp (tag, "<BR>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2390 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2391 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2392 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393 } else if (!g_strcasecmp (tag, "<HR>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2394 !g_strncasecmp (tag, "<HR ", strlen ("<HR "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2395 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2396 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397 NEW_BIT (NEW_SEP_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 } else if (!g_strncasecmp (tag, "<FONT ", strlen ("<FONT "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399 gchar *t, *e, *a, *value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400 FontDetail *font = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2402 gint saw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2403 gint i;
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 t = tag + strlen ("<FONT ");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2407 while (*t != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2408 value = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 saw = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2410
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 while (g_strncasecmp (t, "COLOR=", strlen ("COLOR="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412 && g_strncasecmp (t, "BACK=", strlen ("BACK="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 && g_strncasecmp (t, "FACE=", strlen ("FACE="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2414 && g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2415 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 t++;
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 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2423 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425 if (!g_strncasecmp (t, "COLOR=", strlen ("COLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 t += strlen ("COLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2427 saw = 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2428 } else if (!g_strncasecmp (t, "BACK=", strlen ("BACK="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429 t += strlen ("BACK=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 saw = 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 } else if (!g_strncasecmp (t, "FACE=", strlen ("FACE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 t += strlen ("FACE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433 saw = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434 } else if (!g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 t += strlen ("SIZE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436 saw = 4;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2438
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 if (!saw)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2440 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2441
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2442 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2443 e = a = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2444 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2445 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2446 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2447 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2448 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2449 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 *t = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2451 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 e = a = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2457 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2458 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2459 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2460
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461 if (value == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462 continue;
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 if (font == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2465 font = g_new0 (FontDetail, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2466
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2467 switch (saw) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2468 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2469 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2470 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2471 if ( (font->fore == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2472 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 font->fore = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2475 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476 case 2:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2477 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2478 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479 if ( (font->back == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2480 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481 font->back = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2482 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2483 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2484 case 3:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2485 if ( (font->face == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2486 !(options & GTK_IMHTML_NO_FONTS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2487 font->face = g_strdup (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2488 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2489 case 4:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2490 if ((font->size != 0) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 (options & GTK_IMHTML_NO_SIZES))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 if (isdigit ((gint) value [0])) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495 for (i = 0; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2496 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2499 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2500
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2501 sscanf (value, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505 if ((value [0] == '+') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2506 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2507 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2508 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2509 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2513 font->size += 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2514 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515 }
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 if ((value [0] == '-') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2518 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2523
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2525 font->size = MIN (font->size, 2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2526 font->size = 3 - font->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2527 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2528 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2529
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2530 break;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2533 g_free (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2534 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2535
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
2536 if (!font || !(font->size || font->face || font->fore || font->back)) {
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2537 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2538 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2539 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2540 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2541
1738
bcd7f80f0086 [gaim-migrate @ 1748]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1703
diff changeset
2542 NEW_BIT (NEW_TEXT_BIT);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2544 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 FontDetail *oldfont = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2546 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2547 font->size = oldfont->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2548 if (!font->face)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2549 font->face = g_strdup (oldfont->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2550 if (!font->fore && oldfont->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2551 font->fore = gdk_color_copy (oldfont->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2552 if (!font->back && oldfont->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2553 font->back = gdk_color_copy (oldfont->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2554 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2556 font->size = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2557 if (!font->face)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558 font->face = g_strdup ("helvetica");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2559 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2560
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2561 fonts = g_slist_prepend (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2562 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2563 } else if (!g_strcasecmp (tag, "</FONT>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2564 FontDetail *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2565
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2566 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2567 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2568 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2569 font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2570 fonts = g_slist_remove (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2571 g_free (font->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2572 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2573 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2574 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2575 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2576 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2577 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2578 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2579 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2580 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2581 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2582 } else if (!g_strncasecmp (tag, "<BODY ", strlen ("<BODY "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2583 gchar *t, *e, *color = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2584 GdkColor *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2585
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2586 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2587
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2588 if (!(options & GTK_IMHTML_NO_COLOURS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2589 t = tag + strlen ("<BODY");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2590 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2591 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2592 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2593 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2594 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2595 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2596 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2597 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2598 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2599 } while (g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2600
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2601 if (!g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2602 t += strlen ("BGCOLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2603 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2604 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2605 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2606 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2607 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2608 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2609 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2610 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2611 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2612 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2613 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2614 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2615 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2616 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2617
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2618 if (color != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2619 tmp = gtk_imhtml_get_color (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2620 g_free (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2621 if (tmp != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2622 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2623 bg = tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2624 UPDATE_BG_COLORS;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2625 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2626 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2627 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2628 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2629 } else if (!g_strncasecmp (tag, "<A ", strlen ("<A "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2630 gchar *t, *e;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2631
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2632 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2633 NEW_BIT (NEW_TEXT_BIT);
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 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2636 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2637 url = NULL;
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 t = tag + strlen ("<A");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2640 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2641 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2642 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2643 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2644 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2645 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2646 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2647 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2648 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2649 } while (g_strncasecmp (t, "HREF=", strlen ("HREF=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2650
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2651 if (!g_strncasecmp (t, "HREF=", strlen ("HREF="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2652 t += strlen ("HREF=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2653 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2654 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2655 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2656 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2657 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2658 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2659 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2660 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2661 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2662 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2663 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2664 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2665 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2666 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2667 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2668 } else if (!g_strcasecmp (tag, "</A>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2669 if (url != NULL) {
1524
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
2670 got_tag = TRUE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2671 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2672 g_free (url);
1524
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
2673 url = NULL;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
2674 } else {
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
2675 intag = FALSE;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
2676 tpos = 0;
a5c87ada5143 [gaim-migrate @ 1534]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1519
diff changeset
2677 continue;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2678 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2679 } else if (!g_strncasecmp (tag, "<IMG ", strlen ("<IMG "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2680 gchar *t, *e, *src = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2681 gchar *copy = g_strdup (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2682 gchar **xpm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2683 GdkColor *clr = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2684 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2685
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2686 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2687 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2688
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2689 if (imhtml->img == NULL) {
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2690 ws [wpos] = 0;
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2691 strcat (ws, copy);
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2692 wpos = strlen (ws);
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2693 g_free (copy);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2694 continue;
1453
ecf700f23852 [gaim-migrate @ 1463]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1449
diff changeset
2695 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2696
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2697 t = tag + strlen ("<IMG");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2698 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2699 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2700 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2701 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2702 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2703 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2704 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2705 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2706 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2707 } while (g_strncasecmp (t, "SRC=", strlen ("SRC=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2708
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2709 if (!g_strncasecmp (t, "SRC=", strlen ("SRC="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2710 t += strlen ("SRC=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2711 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2712 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2713 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2714 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2715 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2716 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2717 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2718 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2719 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2720 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2721 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2722 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2723 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2724 }
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2727 if (src == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2728 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2729 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2730 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2731 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2732 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2733 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2734
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2735 xpm = (* imhtml->img) (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2736 if (xpm == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2737 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2738 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2739 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2740 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2741 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2742 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2743 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2744
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2745 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2746
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2747 if (!fonts || ((clr = ((FontDetail *)fonts->data)->back) == NULL))
1460
36c56d591674 [gaim-migrate @ 1470]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1456
diff changeset
2748 clr = (bg != NULL) ? bg : imhtml->default_bg_color;
1428
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 if (!GTK_WIDGET_REALIZED (imhtml))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2751 gtk_widget_realize (GTK_WIDGET (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2752
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2753 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2754 bit->type = TYPE_IMG;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2755 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2756 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2757 clr,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2758 xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2759 if (url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2760 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2761
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2762 NEW_BIT (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2763
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2764 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2765
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2766 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2767 } else if (!g_strcasecmp (tag, "<P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2768 !g_strcasecmp (tag, "</P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2769 !g_strncasecmp (tag, "<P ", strlen ("<P ")) ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2770 !g_strcasecmp (tag, "<H3>") ||
1473
38e8391aa563 [gaim-migrate @ 1483]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1472
diff changeset
2771 !g_strncasecmp (tag, "<H3 ", strlen ("<H3 ")) ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2772 !g_strcasecmp (tag, "</H3>") ||
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2773 !g_strcasecmp (tag, "<HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2774 !g_strcasecmp (tag, "</HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2775 !g_strcasecmp (tag, "<BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2776 !g_strcasecmp (tag, "</BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2777 !g_strcasecmp (tag, "<FONT>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2778 !g_strcasecmp (tag, "<HEAD>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2779 !g_strcasecmp (tag, "</HEAD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2780 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2781 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2782 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2783 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2784
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2785 if (!got_tag) {
1463
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2786 char *d;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2787 tag [tpos] = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2788 d = tag;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2789 while (*d) {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2790 if ((smilelen = gtk_imhtml_is_smiley (imhtml, d)) != 0) {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2791 ws [wpos] = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2792 wpos = 0;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2793 NEW_BIT (NEW_TEXT_BIT);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2794 g_snprintf (ws, smilelen + 1, "%s", d);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2795 NEW_BIT (NEW_SMILEY_BIT);
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2796 d += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2797 } else if (*d == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2798 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2799 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2800 if (is_amp_escape (d, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2801 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2802 d += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2803 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2804 ws [wpos++] = *d++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2805 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2806 } else if (*d == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2807 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2808 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2809 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2810 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2811 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2812 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2813 d++;
1463
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2814 } else {
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2815 ws [wpos++] = *d++;
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2816 }
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2817 }
2f317467d2f9 [gaim-migrate @ 1473]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1462
diff changeset
2818 tpos = 0;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2819 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2820 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2821 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2822 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2823 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 } else if (*c == '&' && !intag) {
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2825 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2826 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2827 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2828 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2829 c += length;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2830 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2831 ws [wpos++] = *c++;
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 } else if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2834 if (*c == '\"')
1703
acce65ffdc80 [gaim-migrate @ 1713]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1691
diff changeset
2835 tagquote++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2836 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2837 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2838 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2839 } else if (((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2840 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2841 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2842 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2843 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2844 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2845 c += smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2846 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2847 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2848 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2849 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2850 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2851 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2852 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2853 c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2854 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2855 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2856 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2857 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2858
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2859 if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2860 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2862 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2863 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2864 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2865 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2866 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2867 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2868 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869 c += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2870 } else if (*c == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2871 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2872 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2873 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2874 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2875 c += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2876 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2877 ws [wpos++] = *c++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2878 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2879 } else if (*c == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2880 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2881 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2882 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2883 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2884 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2885 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2886 c++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2887 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2888 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2889 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2890 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2891 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2892 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2893 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2894 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2895 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2896 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2897 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2898 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2899 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2900 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2901 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2902 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2903 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2904 c += smilelen;
1472
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2905 } else if (*c == '&') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2906 gchar replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2907 gint length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2908 if (is_amp_escape (c, &replace, &length)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2909 ws [wpos++] = replace;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2910 c += length;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2911 } else {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2912 ws [wpos++] = *c++;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2913 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2914 } else if (*c == '\n') {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2915 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2916 ws [wpos] = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2917 wpos = 0;
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2918 NEW_BIT (NEW_TEXT_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2919 NEW_BIT (NEW_BR_BIT);
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2920 }
be620a051d6d [gaim-migrate @ 1482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1463
diff changeset
2921 c++;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2922 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2923 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2924 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2925 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2926 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2927
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2928 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2929 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2930
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2931 while (newbits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2932 GtkIMHtmlBit *bit = newbits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2933 imhtml->bits = g_list_append (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2934 newbits = g_list_remove (newbits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2935 gtk_imhtml_draw_bit (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2936 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2937
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2938 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y + 5);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2939
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2940 if (!(options & GTK_IMHTML_NO_SCROLL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2941 scrolldown &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2942 (imhtml->y + 5 >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2943 gtk_adjustment_set_value (vadj, imhtml->y + 5 - GTK_WIDGET (imhtml)->allocation.height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2944
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2945 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2946 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2947 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2948 retval = g_string_append (retval, "</A>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2949 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2950 if (bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2951 gdk_color_free (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2952 while (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2953 FontDetail *font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2954 fonts = g_slist_remove (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2955 g_free (font->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2956 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2957 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2958 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2959 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2960 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2961 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2962 retval = g_string_append (retval, "</FONT>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2963 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2964 if (retval) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2965 while (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2966 retval = g_string_append (retval, "</B>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2967 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2968 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2969 while (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2970 retval = g_string_append (retval, "</I>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2971 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2972 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2973 while (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2974 retval = g_string_append (retval, "</U>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2975 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2976 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2977 while (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2978 retval = g_string_append (retval, "</S>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2979 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2980 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2981 while (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2982 retval = g_string_append (retval, "</SUB>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2983 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2984 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2985 while (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2986 retval = g_string_append (retval, "</SUP>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2987 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2988 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2989 while (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2990 retval = g_string_append (retval, "</TITLE>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2991 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2992 }
1691
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2993 while (pre) {
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2994 retval = g_string_append (retval, "</PRE>");
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2995 pre--;
d802b115800f [gaim-migrate @ 1701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1647
diff changeset
2996 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2997 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2998 g_free (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2999 g_free (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3000
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3001 return retval;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3002 }
1780
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3003
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3004 void
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3005 gtk_imhtml_clear (GtkIMHtml *imhtml)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3006 {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3007 g_return_if_fail (imhtml != NULL);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3008 g_return_if_fail (GTK_IS_IMHTML (imhtml));
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3009
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3010 while (imhtml->bits) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3011 GtkIMHtmlBit *bit = imhtml->bits->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3012 imhtml->bits = g_list_remove (imhtml->bits, bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3013 if (bit->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3014 g_free (bit->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3015 if (bit->font)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3016 gdk_font_unref (bit->font);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3017 if (bit->fore)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3018 gdk_color_free (bit->fore);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3019 if (bit->back)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3020 gdk_color_free (bit->back);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3021 if (bit->bg)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3022 gdk_color_free (bit->bg);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3023 if (bit->url)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3024 g_free (bit->url);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3025 if (bit->pm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3026 gdk_pixmap_unref (bit->pm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3027 if (bit->bm)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3028 gdk_bitmap_unref (bit->bm);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3029 while (bit->chunks) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3030 struct line_info *li = bit->chunks->data;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3031 if (li->text)
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3032 g_free (li->text);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3033 bit->chunks = g_list_remove (bit->chunks, li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3034 g_free (li);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3035 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3036 g_free (bit);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3037 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3038
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3039 while (imhtml->urls) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3040 g_free (imhtml->urls->data);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3041 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3042 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3043
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3044 if (imhtml->selected_text) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3045 g_string_free (imhtml->selected_text, TRUE);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3046 imhtml->selected_text = g_string_new ("");
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3047 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3048
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3049 if (imhtml->tip_timer) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3050 gtk_timeout_remove (imhtml->tip_timer);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3051 imhtml->tip_timer = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3052 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3053 if (imhtml->tip_window) {
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3054 gtk_widget_destroy (imhtml->tip_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3055 imhtml->tip_window = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3056 }
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3057 imhtml->tip_bit = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3058
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3059 gdk_window_set_cursor (GTK_LAYOUT (imhtml)->bin_window, imhtml->arrow_cursor);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3060
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3061 imhtml->x = BORDER_SIZE;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3062 imhtml->y = BORDER_SIZE + 10;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3063 imhtml->llheight = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3064 imhtml->llascent = 0;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3065 imhtml->line = NULL;
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3066
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3067 if (GTK_WIDGET_REALIZED (GTK_WIDGET (imhtml)))
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3068 gdk_window_clear (GTK_LAYOUT (imhtml)->bin_window);
d7cbedd1d651 [gaim-migrate @ 1790]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1738
diff changeset
3069 }