annotate src/gtkimhtml.c @ 1451:f6cc5cb7faf6

[gaim-migrate @ 1461] patch from customdesigned to hopefully fix proxying once and for all. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 31 Jan 2001 08:07:59 +0000
parents 91d84e2073de
children ecf700f23852
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #define TYPE_TEXT 0
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #define TYPE_SMILEY 1
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #define TYPE_IMG 2
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 #define TYPE_SEP 3
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #define TYPE_BR 4
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 #define TYPE_COMMENT 5
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
62 #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
63
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 typedef struct _GtkIMHtmlBit GtkIMHtmlBit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 typedef struct _FontDetail FontDetail;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 struct _GtkIMHtmlBit {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 gint type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 GdkPixmap *pm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 GdkBitmap *bm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 GdkColor *bg;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 gboolean underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 gboolean strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 gchar *url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 struct _FontDetail {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 gushort size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 gchar *face;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 GdkColor *fore;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 GdkColor *back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 struct line_info {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 gint height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 gint ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 gboolean selected;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 gchar *sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 gchar *sel_end;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 struct url_widget {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 gint x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 gint y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 gint height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 gchar *url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 static GtkLayoutClass *parent_class = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 TARGET_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 TARGET_TEXT,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 TARGET_COMPOUND_TEXT
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 enum {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 URL_CLICKED,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 LAST_SIGNAL
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 static guint signals [LAST_SIGNAL] = { 0 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 static void gtk_imhtml_draw_bit (GtkIMHtml *, GtkIMHtmlBit *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 static GdkColor *gtk_imhtml_get_color (const gchar *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 static gint gtk_imhtml_motion_notify_event (GtkWidget *, GdkEventMotion *);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 gtk_imhtml_destroy (GtkObject *object)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 GtkIMHtml *imhtml;
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 imhtml = GTK_IMHTML (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 while (imhtml->bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 GtkIMHtmlBit *bit = imhtml->bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 imhtml->bits = g_list_remove (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 if (bit->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 g_free (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 if (bit->font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 gdk_font_unref (bit->font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 if (bit->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 gdk_color_free (bit->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 if (bit->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 gdk_color_free (bit->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 if (bit->bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 gdk_color_free (bit->bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 if (bit->url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 g_free (bit->url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 if (bit->pm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 gdk_pixmap_unref (bit->pm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 if (bit->bm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 gdk_bitmap_unref (bit->bm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 while (bit->chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
160 struct line_info *li = bit->chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 if (li->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 g_free (li->text);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
163 bit->chunks = g_list_remove (bit->chunks, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 g_free (li);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 g_free (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
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 if (imhtml->selected_text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 gdk_color_free (imhtml->default_fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 gdk_cursor_destroy (imhtml->hand_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 gdk_cursor_destroy (imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 g_hash_table_destroy (imhtml->smiley_hash);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 gtk_imhtml_realize (GtkWidget *widget)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 imhtml = GTK_IMHTML (widget);
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 if (GTK_WIDGET_CLASS (parent_class)->realize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 widget->style = gtk_style_attach (widget->style, widget->window);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 gdk_window_set_events (imhtml->layout.bin_window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 (gdk_window_get_events (imhtml->layout.bin_window)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
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 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, &GTK_WIDGET (imhtml)->style->white);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 static void
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
214 draw_text (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
215 struct line_info *line)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
217 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
218 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
219 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
220 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
221 gfloat xoff, yoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
222
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
223 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
224 gc = gdk_gc_new (window);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
225 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
226 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
227 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
228
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
229 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
230 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
231 gdk_gc_set_foreground (gc, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
232 } else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
233 gdk_gc_copy (gc, GTK_WIDGET (imhtml)->style->white_gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
234
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
235 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
236
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
237 if (!line->text) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
238 gdk_colormap_unref (cmap);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
239 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
240 return;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
241 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
242
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
243 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
244 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
245 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
246 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
247 gdk_string_width (bit->font, line->text), line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
248 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
249
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
250 if (line->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
251 gint width, x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
252 gchar *start, *end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
253 GdkColor col;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
254
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
255 if ((line->sel_start > line->sel_end) && (line->sel_end != NULL)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
256 start = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
257 end = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
258 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
259 start = line->sel_start;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
260 end = line->sel_end;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
261 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
262
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
263 if (start == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
264 x = 0;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
265 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
266 x = gdk_text_width (bit->font, line->text, start - line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
267
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
268 if (end == NULL)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
269 width = gdk_string_width (bit->font, line->text) - x;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
270 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
271 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
272
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
273 col.red = col.green = col.blue = 0xc000;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
274 gdk_color_alloc (cmap, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
275 gdk_gc_set_foreground (gc, &col);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
276
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
277 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
278 width, line->height);
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
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
281 if (bit->url) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
282 GdkColor *tc = gtk_imhtml_get_color ("#0000a0");
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
283 gdk_color_alloc (cmap, tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
284 gdk_gc_set_foreground (gc, tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
285 gdk_color_free (tc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
286 } else if (bit->fore) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
287 gdk_color_alloc (cmap, bit->fore);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
288 gdk_gc_set_foreground (gc, bit->fore);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
289 } else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
290 gdk_gc_copy (gc, GTK_WIDGET (imhtml)->style->black_gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
291
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
292 gdk_draw_string (window, bit->font, gc, line->x - xoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
293 line->y - yoff + line->ascent, line->text);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
294
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
295 if (bit->underline || bit->url)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
296 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
297 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
298 if (bit->strike)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
299 gdk_draw_rectangle (window, gc, TRUE, line->x - xoff,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
300 line->y - yoff + line->ascent - (bit->font->ascent >> 1),
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
301 gdk_string_width (bit->font, line->text), 1);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
302
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
303 gdk_colormap_unref (cmap);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
304 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
305 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
306
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
307 static gint
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
308 draw_img (GtkIMHtml *imhtml,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
309 struct line_info *line)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
310 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
311 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
312 GdkGC *gc;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
313 GdkColormap *cmap;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
314 gint width, height, hoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
315 GdkWindow *window = GTK_LAYOUT (imhtml)->bin_window;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
316 gfloat xoff, yoff;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
317
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
318 bit = line->bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
319 gdk_window_get_size (bit->pm, &width, &height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
320 hoff = (line->height - height) / 2;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
321 xoff = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
322 yoff = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
323 gc = gdk_gc_new (window);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
324 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
325
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
326 if (bit->bg != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
327 gdk_color_alloc (cmap, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
328 gdk_gc_set_foreground (gc, bit->bg);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
329 } else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
330 gdk_gc_copy (gc, GTK_WIDGET (imhtml)->style->white_gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
331
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
332 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
333
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
334 if (bit->back != NULL) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
335 gdk_color_alloc (cmap, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
336 gdk_gc_set_foreground (gc, bit->back);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
337 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
338 width, line->height);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
339 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
340
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
341 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
342
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
343 gdk_colormap_unref (cmap);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
344 gdk_gc_unref (gc);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
345
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
346 return TRUE;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
347 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
348
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
349 static void
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
350 gtk_imhtml_draw_exposed (GtkIMHtml *imhtml)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
351 {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
352 GList *bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
353 GtkIMHtmlBit *bit;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
354 GList *chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
355 struct line_info *line;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
356 GdkRectangle area;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
357
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
358 area.x = GTK_LAYOUT (imhtml)->hadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
359 area.y = GTK_LAYOUT (imhtml)->vadjustment->value;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
360 area.width = GTK_WIDGET (imhtml)->allocation.width;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
361 area.height = GTK_WIDGET (imhtml)->allocation.height;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
362
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
363 bits = imhtml->bits;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
364
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
365 while (bits) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
366 bit = bits->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
367 chunks = bit->chunks;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
368 if (DRAW_IMG (bit)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
369 line = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
370 if ((line->x <= area.x + area.width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
371 (line->y <= area.y + area.height) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
372 (area.x <= line->x + line->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
373 (area.y <= line->y + line->height))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
374 draw_img (imhtml, line);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
375 } else {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
376 while (chunks) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
377 line = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
378 if ((line->x <= area.x + area.width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
379 (line->y <= area.y + area.height) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
380 (area.x <= line->x + line->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
381 (area.y <= line->y + line->height))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
382 draw_text (imhtml, line);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
383 chunks = g_list_next (chunks);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
384 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
385 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
386 bits = g_list_next (bits);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
387 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 gtk_imhtml_draw (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 GdkRectangle *area)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
394 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
395
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
396 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
397 gtk_imhtml_draw_exposed (imhtml);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 gtk_imhtml_style_set (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 GtkStyle *style)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 if (!GTK_WIDGET_REALIZED (widget))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, &GTK_WIDGET (imhtml)->style->white);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 static gint
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
417 gtk_imhtml_expose_event (GtkWidget *widget,
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
418 GdkEventExpose *event)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
420 GtkIMHtml *imhtml;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
421
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
422 g_return_val_if_fail (widget != NULL, FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
423 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
424
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 if (GTK_WIDGET_CLASS (parent_class)->expose_event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
428 imhtml = GTK_IMHTML (widget);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
429 gtk_imhtml_draw_exposed (imhtml);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
430
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
431 return FALSE;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 gtk_imhtml_redraw_all (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 GList *b;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 gfloat oldvalue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 oldvalue = vadj->value / vadj->upper;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 b = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 while (b) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 bit = b->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 b = g_list_next (b);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 while (bit->chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
450 struct line_info *li = bit->chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 if (li->text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 g_free (li->text);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
453 bit->chunks = g_list_remove (bit->chunks, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 g_free (li);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 while (imhtml->urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 g_free (imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 imhtml->urls = g_list_remove (imhtml->urls, imhtml->urls->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 imhtml->y = BORDER_SIZE + 10;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
471 if (GTK_LAYOUT (imhtml)->bin_window)
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
472 gdk_window_clear (GTK_LAYOUT (imhtml)->bin_window);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
473
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 b = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 while (b) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 gtk_imhtml_draw_bit (imhtml, b->data);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 b = g_list_next (b);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
480 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y + 5);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 gtk_adjustment_set_value (vadj, vadj->upper * oldvalue);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 gtk_imhtml_size_allocate (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 GtkAllocation *allocation)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 g_return_if_fail (allocation != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 ( *GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 if (allocation->width == imhtml->xsize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 imhtml->y = BORDER_SIZE + 10;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 imhtml->xsize = allocation->width;
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 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513 gtk_imhtml_select_none (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
528 chunk = chunks->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
529
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
530 if (chunk->selected) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
531 chunk->selected = FALSE;
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
532 chunk->sel_start = chunk->text;
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
533 chunk->sel_end = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
534 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
535 draw_img (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
536 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
537 draw_text (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
538 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 static gchar*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 get_position (struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 gint x,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 gint width = x - chunk->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 gchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 gchar *pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 guint total = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 if (smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 text = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 if (width <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 return text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576 for (pos = text; *pos != '\0'; pos++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 gint char_width = gdk_text_width (chunk->bit->font, pos, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 if ((width > total) && (width <= total + char_width)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 if (width < total + (char_width >> 1))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 return ++pos;
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 total += char_width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 return pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
590 static GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591 append_to_sel (GString *string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
592 struct line_info *chunk,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 gboolean smileys)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
595 GString *new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 gchar *buf;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597 gchar *start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600 switch (chunk->bit->type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601 case TYPE_TEXT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 case TYPE_COMMENT:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 case TYPE_SMILEY:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 if (smileys) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 start = (chunk->sel_start == NULL) ? chunk->bit->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
613 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 start = (chunk->sel_start == NULL) ? chunk->text : chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618 length = (chunk->sel_end == NULL) ? strlen (start) : chunk->sel_end - start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 if (length <= 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 buf = g_strndup (start, length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 case TYPE_BR:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 buf = g_strdup ("\n");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 default:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 return string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 }
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 new_string = g_string_append (string, buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 g_free (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 return new_string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638 #define COORDS_IN_CHUNK(xx, yy) (((xx) < chunk->x + chunk->width) && \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 ((yy) < chunk->y + chunk->height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 gtk_imhtml_select_bits (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 GList *bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 GList *chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 struct line_info *chunk;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 guint startx = imhtml->sel_startx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 starty = imhtml->sel_starty,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 endx = imhtml->sel_endx,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 endy = imhtml->sel_endy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 gchar *new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 gint selection = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 gboolean smileys = imhtml->smileys;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 gboolean redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 gboolean got_start = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 gboolean got_end = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 if (!imhtml->selection)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 return;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 if (imhtml->selected_text) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 g_string_free (imhtml->selected_text, TRUE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 bits = imhtml->bits;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671 while (bits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 bit = bits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 chunks = bit->chunks;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 while (chunks) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
676 chunk = chunks->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 switch (selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 case 0:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680 if (COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 if (COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 if (got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 if (chunk->sel_end != new_pos)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 if (chunk->sel_start > new_pos) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699 chunk->sel_end = chunk->sel_start;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 selection = 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 (chunk->sel_start != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 (chunk->sel_end != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 chunk->sel_start = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 got_end = TRUE;
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 } else if (!COORDS_IN_CHUNK (startx, starty) && !got_start) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718 if (chunk->selected)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 if (!got_start && COORDS_IN_CHUNK (startx, starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 new_pos = get_position (chunk, startx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 got_start = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 } else if (!got_end && COORDS_IN_CHUNK (endx, endy)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739 new_pos = get_position (chunk, endx, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 if ( !chunk->selected ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 (chunk->sel_end != new_pos) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 (chunk->sel_start != chunk->text))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 chunk->sel_end = new_pos;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 selection++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 got_end = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 if ( !chunk->selected ||
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
751 (chunk->sel_end != NULL) ||
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
752 (chunk->sel_start != chunk->text))
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 chunk->selected = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 case 2:
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
761 if (chunk->selected)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 redraw = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 chunk->selected = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 chunk->sel_start = chunk->text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765 chunk->sel_end = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 if (chunk->selected == TRUE)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 imhtml->selected_text = append_to_sel (imhtml->selected_text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 chunk, smileys);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 if (redraw) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
774 if (DRAW_IMG (bit))
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
775 draw_img (imhtml, chunk);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
776 else
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
777 draw_text (imhtml, chunk);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 redraw = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 }
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 chunks = g_list_next (chunks);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 bits = g_list_next (bits);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 }
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 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 scroll_timeout (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791 GdkEventMotion event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793 GdkModifierType mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
796
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797 gdk_window_get_pointer (imhtml->layout.bin_window, &x, &y, &mask);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
799 if (mask & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800 event.is_hint = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801 event.x = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
802 event.y = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 event.state = mask;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805 gtk_imhtml_motion_notify_event (GTK_WIDGET (imhtml), &event);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 gtk_imhtml_motion_notify_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 GdkEventMotion *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
816 GdkModifierType state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
820
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 if (event->is_hint)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 gdk_window_get_pointer (event->window, &x, &y, &state);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 state = event->state;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 if (state & GDK_BUTTON1_MASK) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831 gint height = vadj->page_size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 gint yy = y - vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 if (((yy < 0) || (yy > height)) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 (imhtml->scroll_timer == 0) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 (vadj->upper > vadj->page_size)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837 imhtml->scroll_timer = gtk_timeout_add (100,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 (GtkFunction) scroll_timeout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 diff = (yy < 0) ? (yy >> 1) : ((yy - height) >> 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 gtk_adjustment_set_value (vadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 MIN (vadj->value + diff, vadj->upper - height + 20));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 if (imhtml->selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 imhtml->sel_endy = MAX (y, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848 gtk_imhtml_select_bits (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 }
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 GList *urls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
853
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
854 while (urls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
855 uw = (struct url_widget *) urls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
856 if ((x > uw->x) && (x < uw->x + uw->width) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 (y > uw->y) && (y < uw->y + uw->height)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 gdk_window_set_cursor (imhtml->layout.bin_window, imhtml->hand_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 urls = g_list_next (urls);
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
864
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
865 gdk_window_set_cursor (imhtml->layout.bin_window, imhtml->arrow_cursor);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
866
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
868 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 gtk_imhtml_button_press_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
873 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
874 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 if (event->button == 1) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
880 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881 y = event->y + vadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 imhtml->sel_startx = x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 imhtml->sel_starty = y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 imhtml->selection = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 gtk_imhtml_button_release_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 GdkEventButton *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 GtkIMHtml *imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897 GtkAdjustment *vadj = GTK_LAYOUT (widget)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 GtkAdjustment *hadj = GTK_LAYOUT (widget)->hadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 gint x, y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 if ((event->button == 1) && imhtml->selection) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 x = event->x + hadj->value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 y = event->y + vadj->value;
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 if ((x == imhtml->sel_startx) && (y == imhtml->sel_starty)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906 imhtml->sel_startx = imhtml->sel_starty = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907 imhtml->selection = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 imhtml->sel_endx = MAX (x, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911 imhtml->sel_endy = MAX (y, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
912 gtk_imhtml_select_bits (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
913 }
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 gtk_selection_owner_set (widget, GDK_SELECTION_PRIMARY, event->time);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
916 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
917
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
918 if ((event->button == 1) && (imhtml->selected_text->len == 0)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
919 GList *urls = imhtml->urls;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
920 struct url_widget *uw;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
921
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
922 while (urls) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
923 uw = (struct url_widget *) urls->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
924 if ((x > uw->x) && (x < uw->x + uw->width) &&
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
925 (y > uw->y) && (y < uw->y + uw->height)) {
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
926 gtk_signal_emit (GTK_OBJECT (imhtml), signals [URL_CLICKED], uw->url);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
927 return TRUE;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
928 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
929 urls = g_list_next (urls);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
930 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
931 }
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
932
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933 return TRUE;
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 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 gtk_imhtml_selection_get (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 GtkSelectionData *sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939 guint sel_info,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 guint32 time)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
942 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943 gchar *string;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
944 gint length;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
945
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
946 g_return_if_fail (widget != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 g_return_if_fail (GTK_IS_IMHTML (widget));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948 g_return_if_fail (sel_data->selection == GDK_SELECTION_PRIMARY);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
949
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
950 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 g_return_if_fail (imhtml->selected_text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 g_return_if_fail (imhtml->selected_text->str != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 if (imhtml->selected_text->len <= 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956 string = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
957 length = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
958 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959 string = g_strdup (imhtml->selected_text->str);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960 length = strlen (string);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 if (sel_info == TARGET_STRING) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 gtk_selection_data_set (sel_data,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965 GDK_SELECTION_TYPE_STRING,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 8 * sizeof (gchar),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967 (guchar *) string,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 } else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 guchar *text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 GdkAtom encoding;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 gint format;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 gint new_length;
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 gdk_string_to_compound_text (string, &encoding, &format, &text, &new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 gtk_selection_data_set (sel_data, encoding, format, text, new_length);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 gdk_free_compound_text (text);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 if (string)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 g_free (string);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 gtk_imhtml_selection_clear_event (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986 GdkEventSelection *event)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988 GtkIMHtml *imhtml;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 g_return_val_if_fail (widget != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 g_return_val_if_fail (GTK_IS_IMHTML (widget), FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 g_return_val_if_fail (event != NULL, FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 g_return_val_if_fail (event->selection == GDK_SELECTION_PRIMARY, TRUE);
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 if (!gtk_selection_clear (widget, event))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996 return FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998 imhtml = GTK_IMHTML (widget);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 gtk_imhtml_select_none (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 gtk_imhtml_set_scroll_adjustments (GtkLayout *layout,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 if (parent_class->set_scroll_adjustments)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 (* parent_class->set_scroll_adjustments) (layout, hadj, vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 gtk_imhtml_class_init (GtkIMHtmlClass *class)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 GtkObjectClass *object_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018 GtkWidgetClass *widget_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 GtkLayoutClass *layout_class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 object_class = (GtkObjectClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022 widget_class = (GtkWidgetClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023 layout_class = (GtkLayoutClass*) class;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 parent_class = gtk_type_class (GTK_TYPE_LAYOUT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1027 signals [URL_CLICKED] =
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028 gtk_signal_new ("url_clicked",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 GTK_RUN_FIRST,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 object_class->type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 GTK_SIGNAL_OFFSET (GtkIMHtmlClass, url_clicked),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 gtk_marshal_NONE__POINTER,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 GTK_TYPE_NONE, 1,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 GTK_TYPE_POINTER);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036 gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038 object_class->destroy = gtk_imhtml_destroy;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 widget_class->realize = gtk_imhtml_realize;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041 widget_class->draw = gtk_imhtml_draw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042 widget_class->style_set = gtk_imhtml_style_set;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1043 widget_class->expose_event = gtk_imhtml_expose_event;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1044 widget_class->size_allocate = gtk_imhtml_size_allocate;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045 widget_class->motion_notify_event = gtk_imhtml_motion_notify_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1046 widget_class->button_press_event = gtk_imhtml_button_press_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1047 widget_class->button_release_event = gtk_imhtml_button_release_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048 widget_class->selection_get = gtk_imhtml_selection_get;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 widget_class->selection_clear_event = gtk_imhtml_selection_clear_event;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 layout_class->set_scroll_adjustments = gtk_imhtml_set_scroll_adjustments;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 static GdkFont*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 gtk_imhtml_font_load (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 gchar *name,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 gboolean bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 gboolean italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 gint fontsize)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 gchar buf [16 * 1024];
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 GdkFont *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 gint size = fontsize ? font_sizes [MIN (fontsize, MAX_SIZE) - 1] : 120;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 bold ? "bold" : "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068 italics ? 'i' : 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1073
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1074 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1076 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1077 bold ? "bold" : "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078 'o',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1087 "bold",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1100 italics ? 'i' : 'r',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1101 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104 return font;
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 (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 "medium",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 'o',
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1113 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 return font;
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 if (!bold && !italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 g_snprintf (buf, sizeof (buf), "-*-%s-medium-r-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 name ? name : DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 return font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1125 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 g_snprintf (buf, sizeof (buf), "-*-%s-medium-r-*-*-*-%d-*-*-*-*-*-*",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 DEFAULT_FONT_NAME,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 font = gdk_font_load (buf);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 if (font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 return font;
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 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 return gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1138 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1140 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 gtk_imhtml_init (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1142 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1143 static const GtkTargetEntry targets [] = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144 { "STRING", 0, TARGET_STRING },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 { "TEXT", 0, TARGET_TEXT },
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 imhtml->default_font = gtk_imhtml_font_load (imhtml, NULL, FALSE, FALSE, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 if (imhtml->default_font == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 g_warning ("GtkIMHtml: Could not load default font!");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 imhtml->default_fg_color = gdk_color_copy (&GTK_WIDGET (imhtml)->style->black);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
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 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 GtkType
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161 gtk_imhtml_get_type (void)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 static GtkType imhtml_type = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 if (!imhtml_type) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 static const GtkTypeInfo imhtml_info = {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 "GtkIMHtml",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 sizeof (GtkIMHtml),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 sizeof (GtkIMHtmlClass),
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170 (GtkClassInitFunc) gtk_imhtml_class_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 (GtkObjectInitFunc) gtk_imhtml_init,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 NULL,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 NULL
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 };
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177 imhtml_type = gtk_type_unique (GTK_TYPE_LAYOUT, &imhtml_info);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 return imhtml_type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 gtk_imhtml_init_smiley_hash (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 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
1190
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 gtk_imhtml_associate_smiley (imhtml, ":)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 gtk_imhtml_associate_smiley (imhtml, ":-)", smile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 gtk_imhtml_associate_smiley (imhtml, ":(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 gtk_imhtml_associate_smiley (imhtml, ":-(", sad_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 gtk_imhtml_associate_smiley (imhtml, ";)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 gtk_imhtml_associate_smiley (imhtml, ";-)", wink_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 gtk_imhtml_associate_smiley (imhtml, ":-p", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 gtk_imhtml_associate_smiley (imhtml, ":-P", tongue_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 gtk_imhtml_associate_smiley (imhtml, "=-O", scream_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 gtk_imhtml_associate_smiley (imhtml, ":-*", kiss_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 gtk_imhtml_associate_smiley (imhtml, ">:o", yell_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 gtk_imhtml_associate_smiley (imhtml, "8-)", smile8_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 gtk_imhtml_associate_smiley (imhtml, ":-$", moneymouth_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 gtk_imhtml_associate_smiley (imhtml, ":-!", burp_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 gtk_imhtml_associate_smiley (imhtml, ":-[", embarrassed_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 gtk_imhtml_associate_smiley (imhtml, ":'(", cry_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 gtk_imhtml_associate_smiley (imhtml, ":-/", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 gtk_imhtml_associate_smiley (imhtml, ":-\\", think_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 gtk_imhtml_associate_smiley (imhtml, ":-X", crossedlips_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 gtk_imhtml_associate_smiley (imhtml, ":-D", bigsmile_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 gtk_imhtml_associate_smiley (imhtml, "O:-)", angel_xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 GtkWidget*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 gtk_imhtml_new (GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224 GtkIMHtml *imhtml = gtk_type_new (GTK_TYPE_IMHTML);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 gtk_imhtml_set_adjustments (imhtml, hadj, vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 imhtml->bits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229 imhtml->urls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 imhtml->y = BORDER_SIZE + 10;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235 imhtml->line = NULL;
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 imhtml->selected_text = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 imhtml->scroll_timer = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240 imhtml->img = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 imhtml->smileys = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 imhtml->comments = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1245 imhtml->smin = G_MAXINT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 imhtml->smax = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1247 gtk_imhtml_init_smiley_hash (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1248
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 return GTK_WIDGET (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1250 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1252 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 gtk_imhtml_set_adjustments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254 GtkAdjustment *hadj,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 GtkAdjustment *vadj)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 gtk_layout_set_hadjustment (GTK_LAYOUT (imhtml), hadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 gtk_layout_set_vadjustment (GTK_LAYOUT (imhtml), vadj);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262 gtk_imhtml_set_defaults (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1263 GdkFont *font,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1264 GdkColor *fg_color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 g_return_if_fail (GTK_IS_IMHTML (imhtml));
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 if (font) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 if (imhtml->default_font)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 gdk_font_unref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 imhtml->default_font = gdk_font_ref (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 }
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 if (fg_color) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 if (imhtml->default_fg_color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277 gdk_color_free (imhtml->default_fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1278 imhtml->default_fg_color = gdk_color_copy (fg_color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 gtk_imhtml_set_img_handler (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 GtkIMHtmlImage handler)
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 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1289 imhtml->img = handler;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 gchar **xpm)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 g_return_if_fail (text != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 if (strlen (text) < imhtml->smin)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302 imhtml->smin = strlen (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1304 if (strlen (text) > imhtml->smax)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305 imhtml->smax = strlen (text);
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 if (xpm == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308 g_hash_table_remove (imhtml->smiley_hash, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 g_hash_table_insert (imhtml->smiley_hash, text, xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1313 /*
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 draw_line (GtkWidget *widget,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1316 GdkEvent *event,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1317 gpointer data)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 GdkDrawable *drawable;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 GdkColormap *cmap;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322 GdkGC *gc;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323 guint max_width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324 guint max_height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326 bit = data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1327 drawable = widget->window;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1328 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1329 gc = gdk_gc_new (drawable);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1330
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1331 if (bit->bg != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1332 gdk_color_alloc (cmap, bit->bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1333 gdk_gc_set_foreground (gc, bit->bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1334
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1335 gdk_draw_rectangle (widget->window, gc, TRUE, 0, 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1336 widget->allocation.width,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1337 widget->allocation.height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1338 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 gdk_gc_copy (gc, widget->style->black_gc);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342 max_width = widget->allocation.width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1343 max_height = widget->allocation.height / 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1344
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 gdk_draw_rectangle (drawable, gc,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1346 TRUE,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347 0, max_height / 2,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1348 max_width, max_height);
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 gdk_colormap_unref (cmap);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 gdk_gc_unref (gc);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353 return TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1355 */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1356
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1357 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358 new_line (GtkIMHtml *imhtml)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1359 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360 GList *last = g_list_last (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1361 struct line_info *li;
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 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1364 li = last->data;
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1365 if (li->x + li->width != imhtml->xsize - BORDER_SIZE)
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1366 li->width = imhtml->xsize - BORDER_SIZE - li->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1368
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1369 last = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1370 if (last) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1371 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1372 if (li->height < MIN_HEIGHT) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1373 while (last) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1374 gint diff;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1375 li = last->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1376 diff = MIN_HEIGHT - li->height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1377 li->height = MIN_HEIGHT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1378 li->ascent += diff >> 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1379 last = g_list_next (last);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1380 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1381 imhtml->llheight = MIN_HEIGHT;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1382 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1383 }
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 g_list_free (imhtml->line);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386 imhtml->line = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1387
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1388 imhtml->x = BORDER_SIZE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1389 imhtml->y += imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1390 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1391
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1392 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393 backwards_update (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1394 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1395 gint height,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1396 gint ascent)
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 gint diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 GList *ls = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403 if (height > imhtml->llheight) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1404 diff = height - imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1405
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 ls = imhtml->line;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407 while (ls) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1408 li = ls->data;
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409 li->height += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411 li->ascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 li->ascent += diff >> 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1417 ls = imhtml->urls;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 while (ls) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419 uw = ls->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 if (uw->y + diff > imhtml->y)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 uw->y += diff;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422 ls = g_list_next (ls);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425 imhtml->llheight = height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426 if (ascent)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1427 imhtml->llascent = ascent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 imhtml->llascent += diff >> 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1433 /*
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434 static GtkTooltips *tips = NULL;
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1435 */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1438 add_text_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439 GtkIMHtmlBit *bit,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440 gchar *text)
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 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 gint width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 width = gdk_string_width (bit->font, text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 width = 0;
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 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1455 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456 if (text)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457 li->ascent = MAX (imhtml->llascent, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1460 li->text = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461 li->bit = bit;
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 if (bit->url) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1464 /* FIXME
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 eventbox = gtk_event_box_new ();
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466 gtk_layout_put (GTK_LAYOUT (imhtml), eventbox, imhtml->x, imhtml->y);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467 gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 GTK_SIGNAL_FUNC (click_event_box), imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 gtk_widget_show (eventbox);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1470
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 gtk_container_add (GTK_CONTAINER (eventbox), darea);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1472 */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1474 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1475 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1476 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1477 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1478 uw->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479 uw->url = bit->url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1481
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1482 /*
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 if (!tips)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484 tips = gtk_tooltips_new ();
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485 gtk_tooltips_set_tip (tips, eventbox, bit->url, "");
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1486 */
1428
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
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1489 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1490 imhtml->line = g_list_append (imhtml->line, li);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1492
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1493 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1494 add_img_renderer (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1495 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1496 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1497 struct line_info *li;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1498 struct url_widget *uw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1499 gint width;
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 gdk_window_get_size (bit->pm, &width, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1502
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503 li = g_new0 (struct line_info, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1504 li->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1505 li->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1506 li->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1507 li->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1508 li->ascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1509 li->bit = bit;
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 if (bit->url) {
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1512 /* FIXME
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1513 eventbox = gtk_event_box_new ();
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1514 gtk_layout_put (GTK_LAYOUT (imhtml), eventbox, imhtml->x, imhtml->y);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1515 gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1516 GTK_SIGNAL_FUNC (click_event_box), imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1517 gtk_widget_show (eventbox);
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_container_add (GTK_CONTAINER (eventbox), darea);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1520 */
1428
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 uw = g_new0 (struct url_widget, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1523 uw->x = imhtml->x;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1524 uw->y = imhtml->y;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525 uw->width = width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526 uw->height = imhtml->llheight;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1527 uw->url = bit->url;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528 imhtml->urls = g_list_append (imhtml->urls, uw);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1530 /*
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1531 if (!tips)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 tips = gtk_tooltips_new ();
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533 gtk_tooltips_set_tip (tips, eventbox, bit->url, "");
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1534 */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1535 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1537 bit->chunks = g_list_append (bit->chunks, li);
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1538 imhtml->line = g_list_append (imhtml->line, li);
1428
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 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543 static void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544 gtk_imhtml_draw_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 GtkIMHtmlBit *bit)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 gint width, height;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548 GdkWindow *window;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 GdkGC *gc;
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 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1552 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1553 g_return_if_fail (bit != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1554
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555 window = GTK_LAYOUT (imhtml)->bin_window;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1556 gc = gdk_gc_new (window);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1557
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1558 if ( (bit->type == TYPE_TEXT) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1559 ((bit->type == TYPE_SMILEY) && !imhtml->smileys) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1560 ((bit->type == TYPE_COMMENT) && imhtml->comments)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1561 gchar *copy = g_strdup (bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1562 gint pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1563 gboolean seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1564 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1565
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1566 height = bit->font->ascent + bit->font->descent;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1567 width = gdk_string_width (bit->font, bit->text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1568
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1569 if ((imhtml->x != BORDER_SIZE) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1570 ((imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5) > imhtml->xsize)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1571 gint remain = imhtml->xsize - imhtml->x - BORDER_SIZE - BORDER_SIZE - 5;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1572 while (gdk_text_width (bit->font, copy, pos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573 if (copy [pos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1574 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1575 pos++;
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 if (seenspace) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1578 while (copy [pos - 1] != ' ') pos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1579
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1580 tmp = g_strndup (copy, pos);
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 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1583 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1584 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1585 pos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1586 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1587 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1588 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1589 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1590 }
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 backwards_update (imhtml, bit, height, bit->font->ascent);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1593
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1594 while (pos < strlen (bit->text)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1595 width = gdk_string_width (bit->font, copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596 if (imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5 > imhtml->xsize) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1597 gint newpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 gint remain = imhtml->xsize - imhtml->x - BORDER_SIZE - BORDER_SIZE - 5;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1599 while (gdk_text_width (bit->font, copy + pos, newpos) < remain) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1600 if (copy [pos + newpos] == ' ')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 seenspace = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602 newpos++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1603 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605 if (seenspace)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1606 while (copy [pos + newpos - 1] != ' ') newpos--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1607
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1608 if (newpos == 0)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1609 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1610
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1611 tmp = g_strndup (copy + pos, newpos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1612 pos += newpos;
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 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 seenspace = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 tmp = g_strdup (copy + pos);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621 add_text_renderer (imhtml, bit, tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 pos = strlen (bit->text);
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 imhtml->x += width;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1626 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1627 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1629 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1630 } else if ((bit->type == TYPE_SMILEY) || (bit->type == TYPE_IMG)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1631 gdk_window_get_size (bit->pm, &width, &height);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1632
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1633 if ((imhtml->x != BORDER_SIZE) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1634 ((imhtml->x + width + BORDER_SIZE + BORDER_SIZE + 5) > imhtml->xsize)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1635 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1636 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1637 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1638 } else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1639 backwards_update (imhtml, bit, height, height * 3 / 4);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1640
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1641 add_img_renderer (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1642 } else if (bit->type == TYPE_BR) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1643 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1644 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1645 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1646 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1647 } else if (bit->type == TYPE_SEP) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1648 if (imhtml->llheight) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1649 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1650 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1651 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1652 }
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1653 /* FIXME
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1654 darea = gtk_drawing_area_new ();
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1655 gtk_widget_set_usize (darea, imhtml->xsize - (BORDER_SIZE * 2), HR_HEIGHT * 2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1656 gtk_layout_put (GTK_LAYOUT (imhtml), darea, imhtml->x, imhtml->y);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1657 gtk_signal_connect (GTK_OBJECT (darea), "expose_event",
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1658 GTK_SIGNAL_FUNC (draw_line), bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1659 gtk_widget_show (darea);
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
1660 */
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1661 imhtml->llheight = HR_HEIGHT * 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1662 new_line (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1663 imhtml->llheight = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1664 imhtml->llascent = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1665 add_text_renderer (imhtml, bit, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1666 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1667
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1668 gtk_layout_set_size (GTK_LAYOUT (imhtml), imhtml->xsize, imhtml->y + 5);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1669
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1670 gdk_gc_destroy (gc);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1671 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1672
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1673 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1674 gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1675 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1676 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1677 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1678 g_return_if_fail (GTK_IS_IMHTML (imhtml));
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 imhtml->smileys = show;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1681
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1682 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1683 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1684 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1685
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1686 void
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1687 gtk_imhtml_show_comments (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688 gboolean show)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1690 g_return_if_fail (imhtml != NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1691 g_return_if_fail (GTK_IS_IMHTML (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 imhtml->comments = show;
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 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (imhtml)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 gtk_imhtml_redraw_all (imhtml);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699 static GdkColor *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1700 gtk_imhtml_get_color (const gchar *color)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702 GdkColor c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1703
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1704 gdk_color_parse (color, &c);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1705
1449
91d84e2073de [gaim-migrate @ 1459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1447
diff changeset
1706 return gdk_color_copy (&c);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1707 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1708
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 static gint
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1710 gtk_imhtml_is_smiley (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1711 const gchar *text)
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 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714 gint i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1715
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1716 g_return_val_if_fail (imhtml != NULL, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1717 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718 g_return_val_if_fail (text != NULL, 0);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 tmp = g_malloc (imhtml->smax + 1);
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 for (i = imhtml->smin; i <= imhtml->smax; i++) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 if (strlen (text) < i) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1725 return 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1726 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1727 g_snprintf (tmp, i + 1, "%s", text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1728 if (g_hash_table_lookup (imhtml->smiley_hash, tmp)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1729 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1730 return i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1731 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1735 return 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1736 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1737
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1738 static GtkIMHtmlBit *
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1739 gtk_imhtml_new_bit (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1740 gint type,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1741 gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1742 gint bold,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1743 gint italics,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1744 gint underline,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1745 gint strike,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1746 FontDetail *font,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1747 GdkColor *bg,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1748 gchar *url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1749 {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750 GtkIMHtmlBit *bit = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1751
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1752 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1754
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1755 if ((type == TYPE_TEXT) && ((text == NULL) || (strlen (text) == 0)))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1756 return NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1757
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1758 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1759 bit->type = type;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1760
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1761 if ((text != NULL) && (strlen (text) != 0))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1762 bit->text = g_strdup (text);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1763
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1764 if ((font != NULL) || bold || italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1765 if (font && (bold || italics || font->size || font->face)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1766 bit->font = gtk_imhtml_font_load (imhtml, font->face, bold, italics, font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1767 } else if (bold || italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1768 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1771 if (font && (type != TYPE_BR)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1772 if (font->fore != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1773 bit->fore = gdk_color_copy (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1774
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1775 if (font->back != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1776 bit->back = gdk_color_copy (font->back);
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 }
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 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
1781 (bit->font == NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1782 bit->font = gdk_font_ref (imhtml->default_font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1783
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1784 if (bg != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1785 bit->bg = gdk_color_copy (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1786
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1787 bit->underline = underline;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1788 bit->strike = strike;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1789
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1790 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1791 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1792
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1793 if (type == TYPE_SMILEY) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1794 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1795
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1796 if ((font != NULL) && (font->back != NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1797 clr = font->back;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1798 else
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1799 clr = (bg != NULL) ? bg : &GTK_WIDGET (imhtml)->style->white;
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 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1802 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803 clr,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 g_hash_table_lookup (imhtml->smiley_hash, text));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1806
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1807 return bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 }
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 #define NEW_TEXT_BIT gtk_imhtml_new_bit (imhtml, TYPE_TEXT, ws, bold, italics, underline, strike, \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811 fonts ? fonts->data : NULL, bg, url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1812 #define NEW_SMILEY_BIT gtk_imhtml_new_bit (imhtml, TYPE_SMILEY, ws, bold, italics, underline, strike, \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1813 fonts ? fonts->data : NULL, bg, url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1814 #define NEW_SEP_BIT gtk_imhtml_new_bit (imhtml, TYPE_SEP, NULL, 0, 0, 0, 0, NULL, bg, NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 #define NEW_BR_BIT gtk_imhtml_new_bit (imhtml, TYPE_BR, NULL, 0, 0, 0, 0, \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1816 fonts ? fonts->data : NULL, bg, NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1817 #define NEW_COMMENT_BIT gtk_imhtml_new_bit (imhtml, TYPE_COMMENT, ws, bold, italics, underline, strike, \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1818 fonts ? fonts->data : NULL, bg, url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1819
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1820 #define NEW_BIT(bit) { GtkIMHtmlBit *tmp = bit; if (tmp != NULL) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1821 newbits = g_list_append (newbits, tmp); }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1823 #define UPDATE_BG_COLORS \
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 GdkColormap *cmap; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1826 GList *rev; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1827 cmap = gdk_colormap_new (gdk_visual_get_best (), FALSE); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1828 rev = g_list_last (newbits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1829 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1830 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1831 if (bit->type == TYPE_BR) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1832 break; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835 bit->bg = gdk_color_copy (bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1836 rev = g_list_previous (rev); \
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 if (!rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1839 rev = g_list_last (imhtml->bits); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840 while (rev) { \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1841 GtkIMHtmlBit *bit = rev->data; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1842 if (bit->type == TYPE_BR) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1843 break; \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1844 if (bit->bg) \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1845 gdk_color_free (bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1846 bit->bg = gdk_color_copy (bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1847 gdk_color_alloc (cmap, bit->bg); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1848 rev = g_list_previous (rev); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1849 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1850 gdk_colormap_unref (cmap); \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1851 } \
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1852 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1853
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1854 GString*
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1855 gtk_imhtml_append_text (GtkIMHtml *imhtml,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1856 const gchar *text,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1857 GtkIMHtmlOptions options)
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 const gchar *c;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1860 gboolean intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1861 gboolean tagquote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1862 gboolean incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1863 gchar *ws;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1864 gchar *tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1865 gint wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1866 gint tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1867 int smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1868 GList *newbits = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1869
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1870 guint bold = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1871 italics = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872 underline = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 strike = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1874 sub = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1875 sup = 0,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1876 title = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1877 GSList *fonts = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1878 GdkColor *bg = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1879 gchar *url = NULL;
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 GtkAdjustment *vadj;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1882 gboolean scrolldown = TRUE;
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 GString *retval = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1885
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1886 g_return_val_if_fail (imhtml != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1887 g_return_val_if_fail (GTK_IS_IMHTML (imhtml), NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1888 g_return_val_if_fail (text != NULL, NULL);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1889
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1890 if (options & GTK_IMHTML_RETURN_LOG)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1891 retval = g_string_new ("");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1893 vadj = GTK_LAYOUT (imhtml)->vadjustment;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1894 if ((vadj->value < imhtml->y + 5 - GTK_WIDGET (imhtml)->allocation.height) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1895 (vadj->upper >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1896 scrolldown = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1898 c = text;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1899 ws = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1900 tag = g_malloc (strlen (text) + 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1901
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1902 ws [0] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1903
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1904 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1905 if (*c == '<') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1906 if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1907 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1908 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1909 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1910 strcat (ws, tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1911 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1912 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1913
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1914 if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1915 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1916 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1917 }
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 if (!g_strncasecmp (c, "<!--", strlen ("<!--"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1920 if (!(options & GTK_IMHTML_NO_COMMENTS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1921 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1922 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1923 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1924 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1925 incomment = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1926 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1927 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1928 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1929 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1930 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1931 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1932 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1933 }
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 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1936 intag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1937 } else if (incomment && (*c == '-') && !g_strncasecmp (c, "-->", strlen ("-->"))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1938 gchar *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1939 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1940 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1941 tmp = g_strdup (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1942 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1943 strcat (ws, tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1944 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1945 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1946 strcat (ws, tmp + strlen ("<!--"));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1947 g_free (tmp);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948 NEW_BIT (NEW_COMMENT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949 incomment = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1950 c += strlen ("-->");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1951 } else if (*c == '>' && intag && !tagquote) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1952 gboolean got_tag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1953 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1954 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1955 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1956
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1957 if (!g_strcasecmp (tag, "<B>") || !g_strcasecmp (tag, "<BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1958 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1959 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1960 bold++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1961 } else if (!g_strcasecmp (tag, "</B>") || !g_strcasecmp (tag, "</BOLD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1962 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963 if (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1964 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1965 bold--;
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 } else if (!g_strcasecmp (tag, "<I>") || !g_strcasecmp (tag, "<ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970 italics++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1971 } else if (!g_strcasecmp (tag, "</I>") || !g_strcasecmp (tag, "</ITALIC>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1972 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973 if (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1977 } else if (!g_strcasecmp (tag, "<U>") || !g_strcasecmp (tag, "<UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980 underline++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 } else if (!g_strcasecmp (tag, "</U>") || !g_strcasecmp (tag, "</UNDERLINE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983 if (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1984 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1985 underline--;
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 } else if (!g_strcasecmp (tag, "<S>") || !g_strcasecmp (tag, "<STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1988 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1989 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1990 strike++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1991 } else if (!g_strcasecmp (tag, "</S>") || !g_strcasecmp (tag, "</STRIKE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1993 if (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1995 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1996 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1997 } else if (!g_strcasecmp (tag, "<SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1998 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1999 sub++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2000 } else if (!g_strcasecmp (tag, "</SUB>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2002 if (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2003 sub--;
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 } else if (!g_strcasecmp (tag, "<SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 sup++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008 } else if (!g_strcasecmp (tag, "</SUP>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2010 if (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2011 sup--;
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 } else if (!g_strcasecmp (tag, "<TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2014 if (options & GTK_IMHTML_NO_TITLE) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2016 title++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2017 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2019 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2020 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2021 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2022 } else if (!g_strcasecmp (tag, "</TITLE>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2023 if (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2024 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2025 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2026 ws [wpos] = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2027 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2028 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2029 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2030 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2031 continue;
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 } else if (!g_strcasecmp (tag, "<BR>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2034 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2035 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2036 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2037 } else if (!g_strcasecmp (tag, "<HR>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2038 !g_strncasecmp (tag, "<HR ", strlen ("<HR "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2039 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2040 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2041 NEW_BIT (NEW_SEP_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2042 } else if (!g_strncasecmp (tag, "<FONT ", strlen ("<FONT "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2043 gchar *t, *e, *a, *value;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2044 FontDetail *font = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2045 GdkColor *clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2046 gint saw;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2047 gint i;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2048
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2049 t = tag + strlen ("<FONT ");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2050
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2051 while (*t != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2052 value = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2053 saw = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2054
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2055 while (g_strncasecmp (t, "COLOR=", strlen ("COLOR="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2056 && g_strncasecmp (t, "BACK=", strlen ("BACK="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2057 && g_strncasecmp (t, "FACE=", strlen ("FACE="))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2058 && g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2059 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2060 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2061 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2062 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2063 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2064 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2065 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2066 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2067 }
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 if (!g_strncasecmp (t, "COLOR=", strlen ("COLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2070 t += strlen ("COLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2071 saw = 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2072 } else if (!g_strncasecmp (t, "BACK=", strlen ("BACK="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2073 t += strlen ("BACK=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2074 saw = 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2075 } else if (!g_strncasecmp (t, "FACE=", strlen ("FACE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2076 t += strlen ("FACE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2077 saw = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2078 } else if (!g_strncasecmp (t, "SIZE=", strlen ("SIZE="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2079 t += strlen ("SIZE=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2080 saw = 4;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2081 }
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 if (!saw)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2084 continue;
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 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2087 e = a = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2088 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2089 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2090 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2091 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2092 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2093 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2094 *t = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2095 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2096 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2097 e = a = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2098 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2099 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2100 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2101 t = e + 1;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2102 value = g_strdup (a);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2103 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2104
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2105 if (value == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2106 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2107
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2108 if (font == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2109 font = g_new0 (FontDetail, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2110
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2111 switch (saw) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2112 case 1:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2113 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2114 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2115 if ( (font->fore == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2116 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2117 font->fore = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2118 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2119 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2120 case 2:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2121 clr = gtk_imhtml_get_color (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2122 if (clr != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2123 if ( (font->back == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2124 !(options & GTK_IMHTML_NO_COLOURS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2125 font->back = clr;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2126 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2127 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2128 case 3:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2129 if ( (font->face == NULL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2130 !(options & GTK_IMHTML_NO_FONTS))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2131 font->face = g_strdup (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2132 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2133 case 4:
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2134 if ((font->size != 0) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2135 (options & GTK_IMHTML_NO_SIZES))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2136 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2137
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2138 if (isdigit ((gint) value [0])) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2139 for (i = 0; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2140 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2141 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2142 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2143 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2144
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2145 sscanf (value, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2146 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2147 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2148
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2149 if ((value [0] == '+') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2150 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2151 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2152 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2153 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2154 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2155
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2156 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2157 font->size += 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2158 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2159 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2160
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2161 if ((value [0] == '-') && (value [1] != '\0')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2162 for (i = 1; i < strlen (value); i++)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2163 if (!isdigit ((gint) value [i]))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2164 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2165 if (i != strlen (value))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2166 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2167
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2168 sscanf (value + 1, "%hd", &font->size);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2169 font->size = MIN (font->size, 2);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170 font->size = 3 - font->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2171 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2172 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2173
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2174 break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2175 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2176
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2177 g_free (value);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2178 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2179
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2180 if (!font) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2181 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2182 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2183 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2184 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2185
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2186 if (!(font->size || font->face || font->fore || font->back)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2187 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2188 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2189 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2190 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2191 }
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 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2194
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2195 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2196 FontDetail *oldfont = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2197 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2198 font->size = oldfont->size;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2199 if (!font->face)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2200 font->face = g_strdup (oldfont->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2201 if (!font->fore && oldfont->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2202 font->fore = gdk_color_copy (oldfont->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2203 if (!font->back && oldfont->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2204 font->back = gdk_color_copy (oldfont->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2205 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2206 if (!font->size)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207 font->size = 3;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 if (!font->face)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2209 font->face = g_strdup ("helvetica");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2211
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2212 fonts = g_slist_prepend (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2213 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2214 } else if (!g_strcasecmp (tag, "</FONT>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2215 FontDetail *font;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2216
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2217 if (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2218 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2219 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2221 fonts = g_slist_remove (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2222 g_free (font->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2223 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2224 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2225 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2226 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2227 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2228 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2229 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2230 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2232 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233 } else if (!g_strncasecmp (tag, "<BODY ", strlen ("<BODY "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 gchar *t, *e, *color = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235 GdkColor *tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2237 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 if (!(options & GTK_IMHTML_NO_COLOURS)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240 t = tag + strlen ("<BODY");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2242 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2244 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2245 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2246 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2248 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2250 } while (g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 if (!g_strncasecmp (t, "BGCOLOR=", strlen ("BGCOLOR="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253 t += strlen ("BGCOLOR=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2254 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2255 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2258 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 color = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2262 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2263 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2264 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2265 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266 color = g_strdup (t);
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
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2269 if (color != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2270 tmp = gtk_imhtml_get_color (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2271 g_free (color);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272 if (tmp != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2273 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274 bg = tmp;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 UPDATE_BG_COLORS;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2277 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2278 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2280 } else if (!g_strncasecmp (tag, "<A ", strlen ("<A "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281 gchar *t, *e;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2282
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2283 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2284 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2285
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2286 if (url != NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2287 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290 t = tag + strlen ("<A");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2292 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297 t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300 } while (g_strncasecmp (t, "HREF=", strlen ("HREF=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 if (!g_strncasecmp (t, "HREF=", strlen ("HREF="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303 t += strlen ("HREF=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2304 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 url = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2312 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316 url = g_strdup (t);
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 } else if (!g_strcasecmp (tag, "</A>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320 got_tag = TRUE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321 if (url != NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2324 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 url = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 } else if (!g_strncasecmp (tag, "<IMG ", strlen ("<IMG "))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327 gchar *t, *e, *src = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2328 gchar *copy = g_strdup (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2329 gchar **xpm;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2330 GdkColor *clr = NULL;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2331 GtkIMHtmlBit *bit;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2332
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2334 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2336 if (imhtml->img == NULL)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339 t = tag + strlen ("<IMG");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2340 do {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 gboolean quote = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342 if (*t == '\0') break;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2343 while (*t && !((*t == ' ') && !quote)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2344 if (*t == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2345 quote = ! quote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2346 t++;
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 while (*t && (*t == ' ')) t++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 } while (g_strncasecmp (t, "SRC=", strlen ("SRC=")));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2350
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 if (!g_strncasecmp (t, "SRC=", strlen ("SRC="))) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2352 t += strlen ("SRC=");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353 if ((*t == '\"') || (*t == '\'')) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2354 e = ++t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2355 while (*e && (*e != *(t - 1))) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2356 if (*e != '\0') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2358 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2360 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2361 e = t;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2362 while (*e && !isspace ((gint) *e)) e++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2363 if (*e == '\0') e--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2364 *e = '\0';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2365 src = g_strdup (t);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2367 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 if (src == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2371 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2373 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2377 xpm = (* imhtml->img) (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2378 if (xpm == NULL) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 strcat (ws, copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2383 g_free (copy);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387 g_free (copy);
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 if (!fonts || ((clr = ((FontDetail *)fonts->data)->back) == NULL))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2390 clr = (bg != NULL) ? bg : &GTK_WIDGET (imhtml)->style->white;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2391
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2392 if (!GTK_WIDGET_REALIZED (imhtml))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393 gtk_widget_realize (GTK_WIDGET (imhtml));
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2394
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2395 bit = g_new0 (GtkIMHtmlBit, 1);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2396 bit->type = TYPE_IMG;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397 bit->pm = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (imhtml)->window,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 &bit->bm,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399 clr,
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400 xpm);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401 if (url)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2402 bit->url = g_strdup (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2403
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2404 NEW_BIT (bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2406 g_free (src);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2407
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2408 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2409 } else if (!g_strcasecmp (tag, "<P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2410 !g_strcasecmp (tag, "</P>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 !g_strncasecmp (tag, "<P ", strlen ("<P ")) ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412 !g_strcasecmp (tag, "<PRE>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 !g_strcasecmp (tag, "</PRE>") ||
1447
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2414 !g_strcasecmp (tag, "<H3>") ||
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2415 !g_strcasecmp (tag, "<H3 ") ||
5df631739769 [gaim-migrate @ 1457]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1428
diff changeset
2416 !g_strcasecmp (tag, "</H3>") ||
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 !g_strcasecmp (tag, "<HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 !g_strcasecmp (tag, "</HTML>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2419 !g_strcasecmp (tag, "<BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 !g_strcasecmp (tag, "</BODY>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2421 !g_strcasecmp (tag, "<FONT>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2422 !g_strcasecmp (tag, "<HEAD>") ||
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2423 !g_strcasecmp (tag, "</HEAD>")) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2425 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 continue;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2427 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2429 if (!got_tag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2431 strcat (ws, tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 wpos = strlen (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2435 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2436 intag = FALSE;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2437 tpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2438 } else if (*c == '&' && !intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2439 if (!g_strncasecmp (c, "&amp;", 5)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2440 ws [wpos++] = '&';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2441 c += 5;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2442 } else if (!g_strncasecmp (c, "&lt;", 4)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2443 ws [wpos++] = '<';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2444 c += 4;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2445 } else if (!g_strncasecmp (c, "&gt;", 4)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2446 ws [wpos++] = '>';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2447 c += 4;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2448 } else if (!g_strncasecmp (c, "&nbsp;", 6)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2449 ws [wpos++] = ' ';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 c += 6;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2451 } else if (!g_strncasecmp (c, "&copy;", 6)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 ws [wpos++] = '©';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 c += 6;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454 } else if (!g_strncasecmp (c, "&quot;", 6)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455 ws [wpos++] = '\"';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2456 c += 6;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2457 } else if (!g_strncasecmp (c, "&reg;", 5)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2458 ws [wpos++] = '®';
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2459 c += 5;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2460 } else if (*(c + 1) == '#') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2461 gint pound = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2462 if (sscanf (c, "&#%d;", &pound) == 1) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2463 if (*(c + 3 + (gint)log10 (pound)) != ';') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2464 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2465 continue;
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 ws [wpos++] = (gchar)pound;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2468 c += 2;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2469 while (isdigit ((gint) *c)) c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2470 if (*c == ';') c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2471 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2472 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2475 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2477 } else if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2478 if (*c == '\"')
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479 tagquote = !tagquote;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2480 tag [tpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2482 ws [wpos++] = *c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2483 } else if (((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2484 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2485 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2486 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2487 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2488 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2489 c += smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2490 } else if (*c == '\n') {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 if (!(options & GTK_IMHTML_NO_NEWLINE)) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495 NEW_BIT (NEW_BR_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2496 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 c++;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2499 ws [wpos++] = *c++;
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 if (intag) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504 tag [tpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2506 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2507 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2508 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2509 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2513 c += smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2514 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515 ws [wpos++] = *c++;
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2518 } else if (incomment) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2521 strcat (tag, ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2522 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2523 c = tag;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2524 while (*c) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2525 if ((smilelen = gtk_imhtml_is_smiley (imhtml, c)) != 0) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2526 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2527 wpos = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2528 NEW_BIT (NEW_TEXT_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2529 g_snprintf (ws, smilelen + 1, "%s", c);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2530 NEW_BIT (NEW_SMILEY_BIT);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2531 c += smilelen;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2532 } else {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2533 ws [wpos++] = *c++;
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 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2536 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2537
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2538 ws [wpos] = 0;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2539 NEW_BIT (NEW_TEXT_BIT);
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 while (newbits) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2542 GtkIMHtmlBit *bit = newbits->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543 imhtml->bits = g_list_append (imhtml->bits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2544 newbits = g_list_remove (newbits, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 gtk_imhtml_draw_bit (imhtml, bit);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2546 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2547
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2548 gtk_widget_set_usize (GTK_WIDGET (imhtml), -1, imhtml->y + 5);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2549
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2550 if (!(options & GTK_IMHTML_NO_SCROLL) &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2551 scrolldown &&
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2552 (imhtml->y + 5 >= GTK_WIDGET (imhtml)->allocation.height))
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2553 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
2554
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2555 if (url) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2556 g_free (url);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2557 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2558 retval = g_string_append (retval, "</A>");
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 if (bg)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2561 gdk_color_free (bg);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2562 while (fonts) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2563 FontDetail *font = fonts->data;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2564 fonts = g_slist_remove (fonts, font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2565 g_free (font->face);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2566 if (font->fore)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2567 gdk_color_free (font->fore);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2568 if (font->back)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2569 gdk_color_free (font->back);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2570 g_free (font);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2571 if (retval)
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2572 retval = g_string_append (retval, "</FONT>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2573 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2574 if (retval) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2575 while (bold) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2576 retval = g_string_append (retval, "</B>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2577 bold--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2578 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2579 while (italics) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2580 retval = g_string_append (retval, "</I>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2581 italics--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2582 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2583 while (underline) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2584 retval = g_string_append (retval, "</U>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2585 underline--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2586 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2587 while (strike) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2588 retval = g_string_append (retval, "</S>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2589 strike--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2590 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2591 while (sub) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2592 retval = g_string_append (retval, "</SUB>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2593 sub--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2594 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2595 while (sup) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2596 retval = g_string_append (retval, "</SUP>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2597 sup--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2598 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2599 while (title) {
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2600 retval = g_string_append (retval, "</TITLE>");
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2601 title--;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2602 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2603 }
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2604 g_free (ws);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2605 g_free (tag);
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2606
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2607 return retval;
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2608 }