annotate src/gtkhtml.c @ 523:023c3851db0a

[gaim-migrate @ 533] fixed some html stuff committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 25 Jul 2000 05:09:14 +0000
parents 58af37870fdd
children 5bf71b39cba2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 337
diff changeset
23 #ifdef HAVE_CONFIG_H
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 337
diff changeset
24 #include "../config.h"
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 337
diff changeset
25 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <stdlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <gtk/gtk.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <gdk/gdkprivate.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <gdk/gdkx.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <gdk/gdkkeysyms.h>
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
33
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
34 #ifndef _WIN32
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include <X11/Xlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include <X11/Xatom.h>
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
37 #endif
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
38
69
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
39 #include "gaim.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 #include "gtkhtml.h"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 #define MAX_SIZE 7
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 #define MIN_HTML_WIDTH_LINES 20
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 #define MIN_HTML_HEIGHT_LINES 10
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 #define BORDER_WIDTH 2
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 #define SCROLL_TIME 100
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 #define SCROLL_PIXELS 5
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 #define KEY_SCROLL_PIXELS 10
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 int font_sizes[] = { 80, 100, 120, 140, 200, 300, 400 };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
52 /*
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 GdkFont *fixed_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 GdkFont *fixed_bold_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55 GdkFont *fixed_italic_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
56 GdkFont *fixed_bold_italic_font[] =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
57 { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58 GdkFont *prop_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 GdkFont *prop_bold_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 GdkFont *prop_italic_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 GdkFont *prop_bold_italic_font[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
62 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
63
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
64 GData * font_cache;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
65 static gboolean cache_init = FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
66
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
67 struct font_state
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
68 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
69 int size;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
70 int owncolor;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
71 int ownbg;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
72 gchar font[1024];
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
73 GdkColor *color;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
74 GdkColor *bgcol;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
75 struct font_state *next;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 struct font_state *push_state(struct font_state *current)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
80 struct font_state *tmp;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
81 tmp = (struct font_state *) g_new0(struct font_state, 1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 tmp->next = current;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 tmp->color = current->color;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 tmp->bgcol = current->bgcol;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 tmp->size = current->size;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 tmp->owncolor = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 tmp->ownbg = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
88 strcpy( tmp->font, current->font );
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 return tmp;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
91
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
92 enum
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
93 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
94 ARG_0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
95 ARG_HADJUSTMENT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
96 ARG_VADJUSTMENT,
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
97 };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
100 enum
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
101 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
102 TARGET_STRING,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
103 TARGET_TEXT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
104 TARGET_COMPOUND_TEXT
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105 };
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
108 static void gtk_html_class_init(GtkHtmlClass * klass);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
109 static void gtk_html_set_arg(GtkObject * object, GtkArg * arg, guint arg_id);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
110 static void gtk_html_get_arg(GtkObject * object, GtkArg * arg, guint arg_id);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
111 static void gtk_html_init(GtkHtml * html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
112 static void gtk_html_destroy(GtkObject * object);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
113 static void gtk_html_finalize(GtkObject * object);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
114 static void gtk_html_realize(GtkWidget * widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
115 static void gtk_html_unrealize(GtkWidget * widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
116 static void gtk_html_style_set(GtkWidget * widget, GtkStyle * previous_style);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
117 static void gtk_html_draw_focus(GtkWidget * widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
118 static void gtk_html_size_request(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
119 GtkRequisition * requisition);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
120 static void gtk_html_size_allocate(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
121 GtkAllocation * allocation);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
122 static void gtk_html_adjustment(GtkAdjustment * adjustment, GtkHtml * html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
123 static void gtk_html_disconnect(GtkAdjustment * adjustment, GtkHtml * html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
124 static void gtk_html_add_seperator(GtkHtml * html);
337
f5b199e20d12 [gaim-migrate @ 347]
Rob Flynn <gaim@robflynn.com>
parents: 306
diff changeset
125 // static void gtk_html_add_pixmap(GtkHtml * html, GdkPixmap * pm, gint fit);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
126 static void gtk_html_add_text(GtkHtml * html,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
127 GdkFont * font,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
128 GdkColor * fore,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
129 GdkColor * back,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
130 gchar * chars,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
131 gint length,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
132 gint uline, gint strike, gchar * url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
133 static void gtk_html_draw_bit(GtkHtml * html,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
134 GtkHtmlBit * htmlbit, gint redraw);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
135 static void gtk_html_selection_get(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
136 GtkSelectionData * selection_data,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
137 guint sel_info, guint32 time);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
138 static gint gtk_html_selection_clear(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
139 GdkEventSelection * event);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
140 static gint gtk_html_visibility_notify(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
141 GdkEventVisibility * event);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
143
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144 /* Event handlers */
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
145 static void gtk_html_draw(GtkWidget * widget, GdkRectangle * area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
146 static gint gtk_html_expose(GtkWidget * widget, GdkEventExpose * event);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
147 static gint gtk_html_button_press(GtkWidget * widget, GdkEventButton * event);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
148 static gint gtk_html_button_release(GtkWidget * widget, GdkEventButton * event);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
149 static gint gtk_html_motion_notify(GtkWidget * widget, GdkEventMotion * event);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
150 static gint gtk_html_key_press(GtkWidget * widget, GdkEventKey * event);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
151 static gint gtk_html_leave_notify(GtkWidget * widget, GdkEventCrossing * event);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
152
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
153 static gint gtk_html_tooltip_timeout(gpointer data);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
154
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
155
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
156 static void clear_area(GtkHtml * html, GdkRectangle * area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
157 static void expose_html(GtkHtml * html, GdkRectangle * area, gboolean cursor);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
158 static void scroll_down(GtkHtml * html, gint diff0);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
159 static void scroll_up(GtkHtml * html, gint diff0);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
160
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
161 static void adjust_adj(GtkHtml * html, GtkAdjustment * adj);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
162 static void resize_html(GtkHtml * html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
163 static gint html_bit_is_onscreen(GtkHtml * html, GtkHtmlBit * hb);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
164 static void draw_cursor(GtkHtml * html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
165 static void undraw_cursor(GtkHtml * html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
167 static GtkWidgetClass *parent_class = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
168
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
169 GtkType gtk_html_get_type(void)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
171 static GtkType html_type = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
172
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
173 if (!html_type)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
174 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
175 static const GtkTypeInfo html_info = {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
176 "GtkHtml",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
177 sizeof(GtkHtml),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
178 sizeof(GtkHtmlClass),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
179 (GtkClassInitFunc) gtk_html_class_init,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
180 (GtkObjectInitFunc) gtk_html_init,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
181 NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
182 NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
183 NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
184 };
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
185 html_type = gtk_type_unique(GTK_TYPE_WIDGET, &html_info);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
186 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
187 return html_type;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
191 static void gtk_html_class_init(GtkHtmlClass * class)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
193 GtkObjectClass *object_class;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
194 GtkWidgetClass *widget_class;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
195
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
196 object_class = (GtkObjectClass *) class;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
197 widget_class = (GtkWidgetClass *) class;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
198 parent_class = gtk_type_class(GTK_TYPE_WIDGET);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
199
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
200
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
201 gtk_object_add_arg_type("GtkHtml::hadjustment",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
202 GTK_TYPE_ADJUSTMENT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
203 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
204 ARG_HADJUSTMENT);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
205
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
206 gtk_object_add_arg_type("GtkHtml::vadjustment",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
207 GTK_TYPE_ADJUSTMENT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
208 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
209 ARG_VADJUSTMENT);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
210
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
211 object_class->set_arg = gtk_html_set_arg;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
212 object_class->get_arg = gtk_html_get_arg;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
213 object_class->destroy = gtk_html_destroy;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
214 object_class->finalize = gtk_html_finalize;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
215
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
216 widget_class->realize = gtk_html_realize;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
217 widget_class->unrealize = gtk_html_unrealize;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
218 widget_class->style_set = gtk_html_style_set;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
219 widget_class->draw_focus = gtk_html_draw_focus;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
220 widget_class->size_request = gtk_html_size_request;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
221 widget_class->size_allocate = gtk_html_size_allocate;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
222 widget_class->draw = gtk_html_draw;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
223 widget_class->expose_event = gtk_html_expose;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
224 widget_class->button_press_event = gtk_html_button_press;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
225 widget_class->button_release_event = gtk_html_button_release;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
226 widget_class->motion_notify_event = gtk_html_motion_notify;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
227 widget_class->leave_notify_event = gtk_html_leave_notify;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
228 widget_class->selection_get = gtk_html_selection_get;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
229 widget_class->selection_clear_event = gtk_html_selection_clear;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 widget_class->key_press_event = gtk_html_key_press;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
231 widget_class->visibility_notify_event = gtk_html_visibility_notify;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
232
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
233
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
234 widget_class->set_scroll_adjustments_signal =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
235 gtk_signal_new("set_scroll_adjustments",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
236 GTK_RUN_LAST,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
237 object_class->type,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
238 GTK_SIGNAL_OFFSET(GtkHtmlClass, set_scroll_adjustments),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
239 gtk_marshal_NONE__POINTER_POINTER,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
240 GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
241 GTK_TYPE_ADJUSTMENT);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
242
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
243
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
244 class->set_scroll_adjustments = gtk_html_set_adjustments;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
245
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
248 static void gtk_html_set_arg(GtkObject * object, GtkArg * arg, guint arg_id)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
250 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
251
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
252 html = GTK_HTML(object);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
253
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
254 switch (arg_id)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
255 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
256 case ARG_HADJUSTMENT:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
257 gtk_html_set_adjustments(html, GTK_VALUE_POINTER(*arg), html->vadj);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
258 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
259 case ARG_VADJUSTMENT:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
260 gtk_html_set_adjustments(html, html->hadj, GTK_VALUE_POINTER(*arg));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
261 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
262 default:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
263 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
264 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
266
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
267 static void gtk_html_get_arg(GtkObject * object, GtkArg * arg, guint arg_id)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
268 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
269 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
270
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
271 html = GTK_HTML(object);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
272
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
273 switch (arg_id)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
274 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
275 case ARG_HADJUSTMENT:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
276 GTK_VALUE_POINTER(*arg) = html->hadj;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
277 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
278 case ARG_VADJUSTMENT:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
279 GTK_VALUE_POINTER(*arg) = html->vadj;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
280 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
281 default:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
282 arg->type = GTK_TYPE_INVALID;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
283 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
284 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
285 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
286
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
287 static void gtk_html_init(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
289 static const GtkTargetEntry targets[] = {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
290 {"STRING", 0, TARGET_STRING},
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
291 {"TEXT", 0, TARGET_TEXT},
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
292 {"COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT}
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
293 };
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
294
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
295 static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
296
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
297 GTK_WIDGET_SET_FLAGS(html, GTK_CAN_FOCUS);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
298
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
299 html->html_area = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
300 html->hadj = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
301 html->vadj = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
302 html->current_x = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303 html->current_y = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
304 html->start_sel = html->end_sel = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
305 html->start_sel_x = html->start_sel_y = -1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
306 html->num_end = html->num_start = -1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
307
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
308 html->html_bits = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
309 html->urls = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310 html->selected_text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
311 html->tooltip_hb = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
312 html->tooltip_timer = -1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
313 html->tooltip_window = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
314 html->cursor_hb = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
315 html->cursor_pos = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
316
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317 html->pm = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
318
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
319 html->editable = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320 html->transparent = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
321
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
322 html->frozen = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
323
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
324 gtk_selection_add_targets(GTK_WIDGET(html), GDK_SELECTION_PRIMARY,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
325 targets, n_targets);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
326
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
327
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
328
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
330
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
331
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
332 GtkWidget *gtk_html_new(GtkAdjustment * hadj, GtkAdjustment * vadj)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
333 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
334 GtkWidget *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
335 if(!cache_init)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
336 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
337 g_datalist_init(&font_cache);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
338 cache_init = TRUE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
339 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
340
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
341 if (hadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
342 g_return_val_if_fail(GTK_IS_ADJUSTMENT(hadj), NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
343 if (vadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
344 g_return_val_if_fail(GTK_IS_ADJUSTMENT(vadj), NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
345
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
346 html = gtk_widget_new(GTK_TYPE_HTML,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
347 "hadjustment", hadj, "vadjustment", vadj, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
348
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
349 return html;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
350 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
351
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
352
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
353 void gtk_html_set_editable(GtkHtml * html, gboolean is_editable)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
354 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
355 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
356 g_return_if_fail(GTK_IS_HTML(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
357
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
358
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
359 html->editable = (is_editable != FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
360
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
361 if (is_editable)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
362 draw_cursor(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
363 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
364 undraw_cursor(html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
365
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
367
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
368 void gtk_html_set_transparent(GtkHtml * html, gboolean is_transparent)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
369 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
370 GdkRectangle rect;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
371 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
372 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
373 GtkWidget *widget;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
374
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
375 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
376 g_return_if_fail(GTK_IS_HTML(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
377
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
378
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
379 widget = GTK_WIDGET(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
380 html->transparent = (is_transparent != FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
381
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
382 if (!GTK_WIDGET_REALIZED(widget))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
383 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
384
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
385 html->bg_gc = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
386 gdk_window_get_size(widget->window, &width, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
387 rect.x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
388 rect.y = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
389 rect.width = width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
390 rect.height = height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
391 gdk_window_clear_area(widget->window, rect.x, rect.y, rect.width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
392 rect.height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
393
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
394 expose_html(html, &rect, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
395 gtk_html_draw_focus((GtkWidget *) html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
397
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
398
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
399 void gtk_html_set_adjustments(GtkHtml * html,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
400 GtkAdjustment * hadj, GtkAdjustment * vadj)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
401 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
402 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
403 g_return_if_fail(GTK_IS_HTML(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
404 if (hadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
405 g_return_if_fail(GTK_IS_ADJUSTMENT(hadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
406 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
407 hadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
408 if (vadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
409 g_return_if_fail(GTK_IS_ADJUSTMENT(vadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
410 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
411 vadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
412
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
413 if (html->hadj && (html->hadj != hadj))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
414 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
415 gtk_signal_disconnect_by_data(GTK_OBJECT(html->hadj), html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
416 gtk_object_unref(GTK_OBJECT(html->hadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
417 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
418
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
419 if (html->vadj && (html->vadj != vadj))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
420 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
421 gtk_signal_disconnect_by_data(GTK_OBJECT(html->vadj), html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
422 gtk_object_unref(GTK_OBJECT(html->vadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
423 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
424
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
425 if (html->hadj != hadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
426 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
427 html->hadj = hadj;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
428 gtk_object_ref(GTK_OBJECT(html->hadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
429 gtk_object_sink(GTK_OBJECT(html->hadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
430
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
431 gtk_signal_connect(GTK_OBJECT(html->hadj), "changed",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
432 (GtkSignalFunc) gtk_html_adjustment, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
433 gtk_signal_connect(GTK_OBJECT(html->hadj), "value_changed",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
434 (GtkSignalFunc) gtk_html_adjustment, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
435 gtk_signal_connect(GTK_OBJECT(html->hadj), "disconnect",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
436 (GtkSignalFunc) gtk_html_disconnect, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
437 gtk_html_adjustment(hadj, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
438 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
439
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
440 if (html->vadj != vadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
441 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
442 html->vadj = vadj;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
443 gtk_object_ref(GTK_OBJECT(html->vadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
444 gtk_object_sink(GTK_OBJECT(html->vadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
445
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
446 gtk_signal_connect(GTK_OBJECT(html->vadj), "changed",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
447 (GtkSignalFunc) gtk_html_adjustment, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
448 gtk_signal_connect(GTK_OBJECT(html->vadj), "value_changed",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
449 (GtkSignalFunc) gtk_html_adjustment, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
450 gtk_signal_connect(GTK_OBJECT(html->vadj), "disconnect",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
451 (GtkSignalFunc) gtk_html_disconnect, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
452 gtk_html_adjustment(vadj, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
453 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
454 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
455
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
456
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
457
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
458 GdkColor *get_color(int colorv, GdkColormap * map)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
459 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
460 GdkColor *color;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
461 #if 0
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
462 fprintf(stdout, "color is %x\n", colorv);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
463 #endif
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
464 color = (GdkColor *) g_new0(GdkColor, 1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
465 color->red = ((colorv & 0xff0000) >> 16) * 256;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
466 color->green = ((colorv & 0xff00) >> 8) * 256;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467 color->blue = ((colorv & 0xff)) * 256;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 #if 0
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
469 fprintf(stdout, "Colors are %d, %d, %d\n", color->red, color->green,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
470 color->blue);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
471 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
472 gdk_color_alloc(map, color);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
473 return color;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
474 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476
286
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
477 int load_font_with_cache(const char *name, const char *weight, char slant,
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
478 int size, GdkFont **font_return)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479 {
286
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
480 gchar font_spec[1024];
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
481
306
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
482 if (size > 0)
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
483 g_snprintf(font_spec, sizeof font_spec,
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
484 "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*",
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
485 name, weight, slant, size);
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
486 else
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
487 g_snprintf(font_spec, sizeof font_spec,
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
488 "-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
286
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
489
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
490 if((*font_return = g_datalist_id_get_data(&font_cache,
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
491 g_quark_from_string(font_spec)))) {
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
492 return TRUE;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
493 } else if ((*font_return = gdk_font_load(font_spec))) {
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
494 g_datalist_id_set_data(&font_cache,
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
495 g_quark_from_string(font_spec), *font_return);
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
496 return TRUE;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
497 } else {
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
498 return FALSE;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
499 }
286
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
500 }
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
501
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
502
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
503 GdkFont *getfont(const char *font, int bold, int italic, int fixed, int size)
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
504 {
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
505 GdkFont *my_font = NULL;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
506 gchar *weight, slant;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
507
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
508 if (!font || !strlen(font)) font = fixed ? "courier" : "helvetica";
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
509 weight = bold ? "bold" : "medium";
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
510 slant = italic ? 'i' : 'r';
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
511
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
512 if (size > MAX_SIZE) size = MAX_SIZE;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
513 if (size < 1) size = 1;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
514 size = font_sizes[size-1];
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
515
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
516 /* try both 'i'talic and 'o'blique for italic fonts, and keep
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
517 * increasing the size until we get one that works. */
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
518
305
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
519 while (size <= 720) {
286
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
520 if (load_font_with_cache(font, weight, slant, size, &my_font))
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
521 return my_font;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
522 if (italic && load_font_with_cache(font, weight, 'o', size, &my_font))
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
523 return my_font;
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
524 size += 10;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
525 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
526
286
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
527 /* since we couldn't get any size up to 72, fall back to the
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
528 * default fonts. */
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
529
37a1d222b7f8 [gaim-migrate @ 296]
Rob Flynn <gaim@robflynn.com>
parents: 137
diff changeset
530 font = fixed ? "courier" : "helvetica";
305
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
531 size = 120;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
532 while (size <= 720) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
533 if (load_font_with_cache(font, weight, slant, size, &my_font))
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
534 return my_font;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
535 size += 10;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
536 }
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
537
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
538 font = fixed ? "helvetica" : "courier";
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
539 size = 120;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
540 while (size <= 720) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
541 if (load_font_with_cache(font, weight, slant, size, &my_font))
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
542 return my_font;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
543 size += 10;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
544 }
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
545
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
546 /* whoops, couldn't do any of those. maybe they have a default outgoing
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
547 * font? maybe we can use that. */
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
548 if (font_options & OPT_FONT_FACE) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
549 if (fontname != NULL) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
550 /* woohoo! */
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
551 size = 120;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
552 while (size <= 720) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
553 if (load_font_with_cache(fontname, "medium", 'r', size, &my_font))
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
554 return my_font;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
555 size += 10;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
556 }
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
557 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
558 }
305
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
559
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
560 /* ok, now we're in a pickle. if we can't do any of the above, let's
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
561 * try doing the most boring font we can find. */
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
562 size = 120;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
563 while (size <= 720) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
564 if (load_font_with_cache("courier", "medium", 'r', size, &my_font))
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
565 return my_font;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
566 size += 10;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
567 }
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
568
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
569 size = 120;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
570 while (size <= 720) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
571 if (load_font_with_cache("helvetica", "medium", 'r', size, &my_font))
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
572 return my_font;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
573 size += 10;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
574 }
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
575
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
576 size = 120;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
577 while (size <= 720) {
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
578 if (load_font_with_cache("times", "medium", 'r', size, &my_font))
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
579 return my_font;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
580 size += 10;
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
581 }
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
582
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
583 /* my god, how did we end up here. is there a 'generic font' function
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
584 * in gdk? that would be incredibly useful here. there's gotta be a
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
585 * better way to do this. */
77404a4692b1 [gaim-migrate @ 315]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 286
diff changeset
586
306
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
587 /* well, if they can't do any of the fonts above, they'll take whatever
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
588 * they can get, and be happy about it, damn it. :) */
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
589 load_font_with_cache("*", "*", '*', -1, &my_font);
a8f964718837 [gaim-migrate @ 316]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 305
diff changeset
590 return my_font;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594 /* 'Borrowed' from ETerm */
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
595 GdkWindow *get_desktop_window(GtkWidget * widget)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
597 #ifndef _WIN32
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
598 GdkAtom prop,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
599 type,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
600 prop2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
601 int format;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
602 gint length;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
603 guchar *data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 GtkWidget *w;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
606 prop = gdk_atom_intern("_XROOTPMAP_ID", 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
607 prop2 = gdk_atom_intern("_XROOTCOLOR_PIXEL", 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
608
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
609 if (prop == None && prop2 == None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
610 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
611 return NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
612 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
613
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
614
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
615
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
616 for (w = widget; w; w = w->parent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
617 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
618
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
619 if (prop != None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
620 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
621 gdk_property_get(w->window, prop, AnyPropertyType, 0L, 1L, 0,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
622 &type, &format, &length, &data);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
623 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
624 else if (prop2 != None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
625 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
626 gdk_property_get(w->window, prop2, AnyPropertyType, 0L, 1L, 0,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
627 &type, &format, &length, &data);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
628 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
629 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
630 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631 continue;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
633 if (type != None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
634 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635 return (w->window);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
638 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639 return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
642
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
643
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
644
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
645 GdkPixmap *get_desktop_pixmap(GtkWidget * widget)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
647 #ifndef _WIN32
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
648 GdkPixmap *p;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
649 GdkAtom prop,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
650 type,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
651 prop2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
652 int format;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
653 gint length;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
654 guint32 id;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
655 guchar *data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
656
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
657 prop = gdk_atom_intern("_XROOTPMAP_ID", 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
658 prop2 = gdk_atom_intern("_XROOTCOLOR_PIXEL", 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
659
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
660
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
661 if (prop == None && prop2 == None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
662 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
663 return NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
664 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
665
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
666 if (prop != None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
667 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
668 gdk_property_get(get_desktop_window(widget), prop, AnyPropertyType, 0L,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
669 1L, 0, &type, &format, &length, &data);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
670 if (type == XA_PIXMAP)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
671 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
672 id = data[0];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
673 id += data[1] << 8;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
674 id += data[2] << 16;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
675 id += data[3] << 24;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
676 p = gdk_pixmap_foreign_new(id);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
677 return p;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
678 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
679 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
680 if (prop2 != None)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
681 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
682
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
683 /* XGetWindowProperty(Xdisplay, desktop_window, prop2, 0L, 1L, False, AnyPropertyType,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
684 &type, &format, &length, &after, &data);*/
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
685
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
686 /* if (type == XA_CARDINAL) {*/
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
687 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
688 * D_PIXMAP((" Solid color not yet supported.\n"));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
689 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
690
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
691 /* return NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692 }*/
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
693 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
694 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
695 * D_PIXMAP(("No suitable attribute found.\n"));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
696 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
697 #endif
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
698 return NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
699 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
700
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
701
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
702 static void clear_focus_area(GtkHtml * html,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
703 gint area_x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
704 gint area_y, gint area_width, gint area_height)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
705 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
706 GtkWidget *widget = GTK_WIDGET(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
707 gint x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
708 y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
709
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
710 gint ythick = BORDER_WIDTH + widget->style->klass->ythickness;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
711 gint xthick = BORDER_WIDTH + widget->style->klass->xthickness;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
712
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
713 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
714 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
715
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
716 if (html->frozen > 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
717 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
718
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
719 if (html->transparent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
720 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
721 if (html->pm == NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
722 html->pm = get_desktop_pixmap(widget);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
723
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
724 if (html->pm == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
725 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
726
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
727 if (html->bg_gc == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
728 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
729 GdkGCValues values;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
730
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
731 values.tile = html->pm;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
732 values.fill = GDK_TILED;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
733
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
734 html->bg_gc = gdk_gc_new_with_values(html->html_area, &values,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
735 GDK_GC_FILL | GDK_GC_TILE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
736
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
737 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
738
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
739 gdk_window_get_deskrelative_origin(widget->window, &x, &y);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
740
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
741 gdk_draw_pixmap(widget->window, html->bg_gc, html->pm,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
742 x + area_x, y + area_y, area_x, area_y, area_width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
743 area_height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
744
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
745
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
746 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
747 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
748 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
749 gdk_window_get_size(widget->style->bg_pixmap[GTK_STATE_NORMAL], &width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
750 &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
751
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
752 gdk_gc_set_ts_origin(html->bg_gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
753 (-html->xoffset + xthick) % width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
754 (-html->yoffset + ythick) % height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
755
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
756 gdk_draw_rectangle(widget->window, html->bg_gc, TRUE,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
757 area_x, area_y, area_width, area_height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
758 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
759 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
760
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
761 static void gtk_html_draw_focus(GtkWidget * widget)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
762 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
763 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
764 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
765 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
766 gint x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
767 y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
768
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
769 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
770 g_return_if_fail(GTK_IS_HTML(widget));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
771
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
772 html = GTK_HTML(widget);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
773
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
774 if (GTK_WIDGET_DRAWABLE(widget))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
775 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
776 gint ythick = widget->style->klass->ythickness;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
777 gint xthick = widget->style->klass->xthickness;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
778 gint xextra = BORDER_WIDTH;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
779 gint yextra = BORDER_WIDTH;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
780
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
781 x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
782 y = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
783 width = widget->allocation.width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
784 height = widget->allocation.height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
785
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
786 if (GTK_WIDGET_HAS_FOCUS(widget))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
787 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
788 x += 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
789 y += 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
790 width -= 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
791 height -= 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
792 xextra -= 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
793 yextra -= 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
794
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
795 gtk_paint_focus(widget->style, widget->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
796 NULL, widget, "text",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
797 0, 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
798 widget->allocation.width - 1,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
799 widget->allocation.height - 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
800 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
801
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
802 gtk_paint_shadow(widget->style, widget->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
803 GTK_STATE_NORMAL, GTK_SHADOW_IN,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
804 NULL, widget, "text", x, y, width, height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
805
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
806 x += xthick;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
807 y += ythick;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
808 width -= 2 * xthick;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
809 height -= 2 * ythick;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
810
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
811
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
812 if (widget->style->bg_pixmap[GTK_STATE_NORMAL] || html->transparent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
813 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
814 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
815 * top rect
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
816 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
817 clear_focus_area(html, x, y, width, yextra);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
818 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
819 * left rect
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
820 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
821 clear_focus_area(html, x, y + yextra,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
822 xextra, y + height - 2 * yextra);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
823 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
824 * right rect
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
825 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
826 clear_focus_area(html, x + width - xextra, y + yextra,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
827 xextra, height - 2 * ythick);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
828 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
829 * bottom rect
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
830 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
831 clear_focus_area(html, x, x + height - yextra, width, yextra);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
832 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
833 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
834 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
835
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
836 static void gtk_html_size_request(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
837 GtkRequisition * requisition)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
838 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
839 gint xthickness;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
840 gint ythickness;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
841 gint char_height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
842 gint char_width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
843
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
844 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
845 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
846 g_return_if_fail(requisition != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
847
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
848 xthickness = widget->style->klass->xthickness + BORDER_WIDTH;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
849 ythickness = widget->style->klass->ythickness + BORDER_WIDTH;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
850
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
851 char_height = MIN_HTML_HEIGHT_LINES * (widget->style->font->ascent +
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
852 widget->style->font->descent);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
853
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
854 char_width = MIN_HTML_WIDTH_LINES * (gdk_text_width(widget->style->font,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
855 "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
856 26) / 26);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
857
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
858 requisition->width = char_width + xthickness * 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
859 requisition->height = char_height + ythickness * 2;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
860 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
861
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
862 static void gtk_html_size_allocate(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
863 GtkAllocation * allocation)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
864 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
865 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
866
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
867 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
868 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
869 g_return_if_fail(allocation != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
870
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
871 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
872
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
873 widget->allocation = *allocation;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
874 if (GTK_WIDGET_REALIZED(widget))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
875 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
876 gdk_window_move_resize(widget->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
877 allocation->x, allocation->y,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
878 allocation->width, allocation->height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
879
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
880 gdk_window_move_resize(html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
881 widget->style->klass->xthickness + BORDER_WIDTH,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
882 widget->style->klass->ythickness + BORDER_WIDTH,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
883 MAX(1, (gint) widget->allocation.width -
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
884 (gint) (widget->style->klass->xthickness +
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
885 (gint) BORDER_WIDTH) * 2),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
886 MAX(1, (gint) widget->allocation.height -
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
887 (gint) (widget->style->klass->ythickness +
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
888 (gint) BORDER_WIDTH) * 2));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
889
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
890 resize_html(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
891 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
892 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
893
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
894 static void gtk_html_draw(GtkWidget * widget, GdkRectangle * area)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
895 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
896 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
897 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
898 g_return_if_fail(area != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
899
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
900 if (GTK_WIDGET_DRAWABLE(widget))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
901 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
902 expose_html(GTK_HTML(widget), area, TRUE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
903 gtk_widget_draw_focus(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
904 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
905 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
906
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
907
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
908 static gint gtk_html_expose(GtkWidget * widget, GdkEventExpose * event)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
909 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
910 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
911
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
912 g_return_val_if_fail(widget != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
913 g_return_val_if_fail(GTK_IS_HTML(widget), FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
914 g_return_val_if_fail(event != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
915
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
916 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
917
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
918 if (event->window == html->html_area)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
919 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
920 expose_html(html, &event->area, TRUE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
921 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
922 else if (event->count == 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
923 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
924 gtk_widget_draw_focus(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
925 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
926
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
927 return FALSE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
928
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
929 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
930
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
931
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
932 static gint gtk_html_selection_clear(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
933 GdkEventSelection * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
934 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
935 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
936
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
937 g_return_val_if_fail(widget != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
938 g_return_val_if_fail(GTK_IS_HTML(widget), FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
939 g_return_val_if_fail(event != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
940
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
941 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
942 * Let the selection handling code know that the selection
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
943 * * has been changed, since we've overriden the default handler
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
944 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
945 if (!gtk_selection_clear(widget, event))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
946 return FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
947
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
948 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
949
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
950 if (event->selection == GDK_SELECTION_PRIMARY)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
951 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
952 if (html->selected_text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
953 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
954 GList *hbits = html->html_bits;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
955 GtkHtmlBit *hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
956
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
957 g_free(html->selected_text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
958 html->selected_text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
959 html->start_sel = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
960 html->end_sel = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
961 html->num_start = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
962 html->num_end = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
963 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
964 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
965 hb = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
966 if (hb->was_selected)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
967 gtk_html_draw_bit(html, hb, 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
968 hbits = hbits->prev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
969 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
970 hbits = g_list_last(html->html_bits);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
971 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
972 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
973
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
974 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
975 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
976
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
977
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
978
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
979 static void gtk_html_selection_get(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
980 GtkSelectionData * selection_data,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
981 guint sel_info, guint32 time)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
982 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
983 gchar *str;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
984 gint len;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
985 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
986
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
987 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
988 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
989
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
990 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
991
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
992
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
993 if (selection_data->selection != GDK_SELECTION_PRIMARY)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
994 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
995
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
996 str = html->selected_text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
997
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
998 if (!str)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
999 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1000
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1001 len = strlen(str);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1002
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1003 if (sel_info == TARGET_STRING)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1004 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1005 gtk_selection_data_set(selection_data,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1006 GDK_SELECTION_TYPE_STRING,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1007 8 * sizeof(gchar), (guchar *) str, len);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1008 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1009 else if ((sel_info == TARGET_TEXT) || (sel_info == TARGET_COMPOUND_TEXT))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1010 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1011 guchar *text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1012 GdkAtom encoding;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1013 gint format;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1014 gint new_length;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1015
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1016 gdk_string_to_compound_text(str, &encoding, &format, &text,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1017 &new_length);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1018 gtk_selection_data_set(selection_data, encoding, format, text,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1019 new_length);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1020 gdk_free_compound_text(text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1021 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1022
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1023
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1024
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1025 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1026
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1027 static void do_select(GtkHtml * html, int x, int y)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1028 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1029 GList *hbits = g_list_last(html->html_bits);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1030 int epos,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1031 spos;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1032 GtkHtmlBit *hb;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1033
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1034 if (!hbits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1035 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1036
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1037 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1038
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1039 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1040 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1041 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1042 if (hb->type == HTML_BIT_TEXT)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1043 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1044 hbits = hbits->prev;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1045 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1046
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1047 if (!hb)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1048 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1049
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1050
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1051 if (y > hb->y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1052 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1053 html->num_end = strlen(hb->text) - 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1054 html->end_sel = hb;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1055 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1056 else if (y < 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1057 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1058 html->num_end = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1059 html->end_sel = (GtkHtmlBit *) html->html_bits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1060 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1061 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1062 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1063 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1064 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1065 if ((y < hb->y && y > (hb->y - hb->height)) &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1066 (x > hb->x + hb->width))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1067 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1068 if (hb->type != HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1069 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1070 html->num_end = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1071 html->end_sel = hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1072 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1073 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1074
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1075 html->num_end = strlen(hb->text) - 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1076 html->end_sel = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1077 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1078 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1079 else if ((x > hb->x && x < (hb->x + hb->width)) &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1080 (y < hb->y && y > (hb->y - hb->height)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1081 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1082 int i,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1083 len;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1084 int w = x - hb->x;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1085
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1086 if (hb->type != HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1087 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1088 html->num_end = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1089 html->end_sel = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1090 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1091 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1092
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1093 len = strlen(hb->text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1094
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1095 for (i = 1; i <= len; i++)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1096 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1097 if (gdk_text_measure(hb->font, hb->text, i) > w)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1098 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1099 html->num_end = i - 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1100 html->end_sel = hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1101 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1102 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1103 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1104 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1105 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1106 hbits = hbits->prev;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1107 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1108
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1109 if (html->end_sel == NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1110 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1111 if (html->start_sel == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1112 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1113 html->start_sel = html->end_sel;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1114 html->num_start = html->num_end;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1115 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1116
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1117 epos = g_list_index(html->html_bits, html->end_sel);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1118 spos = g_list_index(html->html_bits, html->start_sel);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1119 g_free(html->selected_text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1120 html->selected_text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1121
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1122 if (epos == spos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1123 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1124 char *str;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1125 if (html->start_sel->type != HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1126 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1127 html->selected_text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1128 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1129 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1130 if (html->num_end == html->num_start)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1131 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1132 str = g_malloc(2);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1133 if (strlen(html->start_sel->text))
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1134 str[0] = html->start_sel->text[html->num_end];
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1135 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1136 str[0] = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1137 str[1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1138 gtk_html_draw_bit(html, html->start_sel, 0);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1139 html->selected_text = str;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1140 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1141 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1142 {
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 69
diff changeset
1143 size_t st,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1144 en;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1145 char *str;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1146 if (html->num_end > html->num_start)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1147 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1148 en = html->num_end;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1149 st = html->num_start;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1150 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1151 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1152 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1153 en = html->num_start;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1154 st = html->num_end;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1155 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1156
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1157 str = g_malloc(en - st + 2);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1158 strncpy(str, html->start_sel->text + st, (en - st + 1));
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1159 str[en - st + 1] = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1160 gtk_html_draw_bit(html, html->start_sel, 0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1161 html->selected_text = str;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1162
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1163 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1164 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1165 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1166 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1167 GtkHtmlBit *shb,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1168 *ehb;
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 69
diff changeset
1169 size_t en,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1170 st;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1171 int len,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1172 nlen;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1173 char *str;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1174 if (epos > spos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1175 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1176 shb = html->start_sel;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1177 ehb = html->end_sel;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1178 en = html->num_end;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1179 st = html->num_start;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1180 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1181 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1182 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1183 shb = html->end_sel;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1184 ehb = html->start_sel;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1185 en = html->num_start;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1186 st = html->num_end;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1187 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1188
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1189 hbits = g_list_find(html->html_bits, shb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1190
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1191 if (!hbits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1192 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1193
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1194 if (shb->type == HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1195 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1196 len = strlen(shb->text) - st + 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1197 str = g_malloc(len);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1198 strcpy(str, shb->text + st);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1199 str[len - 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1200 gtk_html_draw_bit(html, shb, 0);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1201 if (shb->newline)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1202 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1203 len += 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1204 str = g_realloc(str, len);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1205 str[len - 2] = '\n';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1206 str[len - 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1207 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1208 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1209 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1210 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1211 len = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1212 str = g_malloc(1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1213 str[0] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1214 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1215 if (hbits->next == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1216 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1217 html->selected_text = str;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1218 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1219 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1220
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1221
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1222 hbits = hbits->next;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1223 while (1)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1224 { /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1225 * Yah I know is dangerous :P
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1226 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1227 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1228 if (hb->type != HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1229 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1230 if (hb == ehb)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1231 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1232 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1233 continue;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1234 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1235 if (hb != ehb)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1236 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1237 nlen = len + strlen(hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1238 str = g_realloc(str, nlen);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1239 strcpy(str + (len - 1), hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1240 len = nlen;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1241 str[len - 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1242 gtk_html_draw_bit(html, hb, 0);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1243 if (hb->newline)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1244 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1245 len += 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1246 str = g_realloc(str, len);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1247 str[len - 2] = '\n';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1248 str[len - 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1249 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1250 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1251 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1252 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1253 nlen = len + en + 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1254 str = g_realloc(str, nlen);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1255 strncpy(str + (len - 1), hb->text, en + 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1256 len = nlen;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1257 str[len - 1] = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1258
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1259 gtk_html_draw_bit(html, hb, 0);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1260 if (hb->newline && en == strlen(hb->text))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1261 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1262 len += 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1263 str = g_realloc(str, len);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1264 str[len - 2] = '\n';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1265 str[len - 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1266 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1267 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1268 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1269 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1270 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1271 html->selected_text = str;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1272 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1273
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1274 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1275
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1276 static gint scroll_timeout(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1277 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1278 GdkEventMotion event;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1279 gint x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1280 y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1281 GdkModifierType mask;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1282
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1283 html->timer = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1284 gdk_window_get_pointer(html->html_area, &x, &y, &mask);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1285
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1286 if (mask & GDK_BUTTON1_MASK)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1287 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1288 event.is_hint = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1289 event.x = x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1290 event.y = y;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1291 event.state = mask;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1292
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1293 gtk_html_motion_notify(GTK_WIDGET(html), &event);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1294 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1295
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1296 return FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1297
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1298 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1299
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1300
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1301 static gint gtk_html_tooltip_paint_window(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1302 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1303 GtkStyle *style;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1304 gint y,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1305 baseline_skip,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1306 gap;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1307
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1308 style = html->tooltip_window->style;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1309
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1310 gap = (style->font->ascent + style->font->descent) / 4;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1311 if (gap < 2)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1312 gap = 2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1313 baseline_skip = style->font->ascent + style->font->descent + gap;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1314
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1315 if (!html->tooltip_hb)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1316 return FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1317
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1318 gtk_paint_flat_box(style, html->tooltip_window->window,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1319 GTK_STATE_NORMAL, GTK_SHADOW_OUT,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1320 NULL, GTK_WIDGET(html->tooltip_window), "tooltip",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1321 0, 0, -1, -1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1322
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1323 y = style->font->ascent + 4;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1324
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1325 gtk_paint_string(style, html->tooltip_window->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1326 GTK_STATE_NORMAL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1327 NULL, GTK_WIDGET(html->tooltip_window), "tooltip",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1328 4, y, "HTML Link:");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1329 y += baseline_skip;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1330 gtk_paint_string(style, html->tooltip_window->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1331 GTK_STATE_NORMAL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1332 NULL, GTK_WIDGET(html->tooltip_window), "tooltip",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1333 4, y, html->tooltip_hb->url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1334
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1335 return FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1336
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1337
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1338 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1339
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1340 static gint gtk_html_tooltip_timeout(gpointer data)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1341 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1342 GtkHtml *html = (GtkHtml *) data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1343
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1344
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1345 GDK_THREADS_ENTER();
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1346
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1347 if (html->tooltip_hb && GTK_WIDGET_DRAWABLE(GTK_WIDGET(html)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1348 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1349 GtkWidget *widget;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1350 GtkStyle *style;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1351 gint gap,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1352 x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1353 y,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1354 w,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1355 h,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1356 scr_w,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1357 scr_h,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1358 baseline_skip;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1359
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1360 if (html->tooltip_window)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1361 gtk_widget_destroy(html->tooltip_window);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1362
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1363 html->tooltip_window = gtk_window_new(GTK_WINDOW_POPUP);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1364 gtk_widget_set_app_paintable(html->tooltip_window, TRUE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1365 gtk_window_set_policy(GTK_WINDOW(html->tooltip_window), FALSE, FALSE,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1366 TRUE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1367 gtk_widget_set_name(html->tooltip_window, "gtk-tooltips");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1368 gtk_signal_connect_object(GTK_OBJECT(html->tooltip_window),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1369 "expose_event",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1370 GTK_SIGNAL_FUNC
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1371 (gtk_html_tooltip_paint_window),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1372 GTK_OBJECT(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1373 gtk_signal_connect_object(GTK_OBJECT(html->tooltip_window), "draw",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1374 GTK_SIGNAL_FUNC
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1375 (gtk_html_tooltip_paint_window),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1376 GTK_OBJECT(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1377
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1378 gtk_widget_ensure_style(html->tooltip_window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1379 style = html->tooltip_window->style;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1380
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1381 widget = GTK_WIDGET(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1382
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1383 scr_w = gdk_screen_width();
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1384 scr_h = gdk_screen_height();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1385
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1386 gap = (style->font->ascent + style->font->descent) / 4;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1387 if (gap < 2)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1388 gap = 2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1389 baseline_skip = style->font->ascent + style->font->descent + gap;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1390
353
a4df8f1cc61a [gaim-migrate @ 363]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
1391 w = 8 + MAX(gdk_string_width(style->font, _("HTML Link:")),
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1392 gdk_string_width(style->font, html->tooltip_hb->url));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1393 ;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1394 h = 8 - gap;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1395 h += (baseline_skip * 2);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1396
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1397 gdk_window_get_pointer(NULL, &x, &y, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1398 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1399 * gdk_window_get_origin (widget->window, NULL, &y);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1400 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1401 if (GTK_WIDGET_NO_WINDOW(widget))
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1402 y += widget->allocation.y;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1403
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1404 x -= ((w >> 1) + 4);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1405
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1406 if ((x + w) > scr_w)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1407 x -= (x + w) - scr_w;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1408 else if (x < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1409 x = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1410
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1411 if ((y + h + 4) > scr_h)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1412 y =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1413 y - html->tooltip_hb->font->ascent +
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1414 html->tooltip_hb->font->descent;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1415 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1416 y =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1417 y + html->tooltip_hb->font->ascent +
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1418 html->tooltip_hb->font->descent;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1419
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1420 gtk_widget_set_usize(html->tooltip_window, w, h);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1421 gtk_widget_popup(html->tooltip_window, x, y);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1422
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1423 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1424
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1425 html->tooltip_timer = -1;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1426
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1427 GDK_THREADS_LEAVE();
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1428
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1429 return FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1430 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1431
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1432
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1433 static gint gtk_html_leave_notify(GtkWidget * widget, GdkEventCrossing * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1434 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1435 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1436
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1437 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1438
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1439 if (html->tooltip_timer != -1)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1440 gtk_timeout_remove(html->tooltip_timer);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1441 if (html->tooltip_window)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1442 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1443 gtk_widget_destroy(html->tooltip_window);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1444 html->tooltip_window = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1445 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1446
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1447
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1448 html->tooltip_hb = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1449 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1450 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1451
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1452
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1453 static gint gtk_html_motion_notify(GtkWidget * widget, GdkEventMotion * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1454 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1455 int x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1456 y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1457 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1458 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1459 GdkModifierType state;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1460 int realx,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1461 realy;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1462 GtkHtml *html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1463
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1464 if (event->is_hint)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1465 gdk_window_get_pointer(event->window, &x, &y, &state);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1466 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1467 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1468 x = event->x;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1469 y = event->y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1470 state = event->state;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1471 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1472
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1473 gdk_window_get_size(html->html_area, &width, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1474
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1475 realx = x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1476 realy = y + html->yoffset;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1477
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1478
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1479 if (state & GDK_BUTTON1_MASK)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1480 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1481 if (realx != html->start_sel_x || realy != html->start_sel_y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1482 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1483 char *tmp = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1484
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1485 if (y < 0 || y > height)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1486 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1487 int diff;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1488 if (html->timer == 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1489 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1490 html->timer = gtk_timeout_add(100,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1491 (GtkFunction) scroll_timeout,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1492 html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1493 if (y < 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1494 diff = y / 2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1495 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1496 diff = (y - height) / 2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1497
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1498 if (html->vadj->value + diff >
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1499 html->vadj->upper - height + 20)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1500 gtk_adjustment_set_value(html->vadj,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1501 html->vadj->upper - height +
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1502 20);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1503 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1504 gtk_adjustment_set_value(html->vadj,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1505 html->vadj->value + diff);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1506
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1507 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1508 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1509
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1510 if (html->selected_text != NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1511 tmp = g_strdup(html->selected_text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1512 do_select(html, realx, realy);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1513 if (tmp)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1514 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1515 if (!html->selected_text || strcmp(tmp, html->selected_text))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1516 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1517 GtkHtmlBit *hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1518 GList *hbits = html->html_bits;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1519 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1520 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1521 hb = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1522 if (hb->was_selected)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1523 gtk_html_draw_bit(html, hb, 0);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1524 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1525 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1526 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1527 g_free(tmp);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1528 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1529 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1530 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1531 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1532 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1533 GtkHtmlBit *hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1534 GList *urls;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1535
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1536 urls = html->urls;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1537 while (urls)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1538 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1539 hb = (GtkHtmlBit *) urls->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1540 if ((realx > hb->x && realx < (hb->x + hb->width)) &&
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1541 (realy < hb->y && realy > (hb->y - hb->height)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1542 {
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1543 GdkCursor *cursor = NULL;
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1544
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1545 if (html->tooltip_hb != hb)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1546 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1547 html->tooltip_hb = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1548 if (html->tooltip_timer != -1)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1549 gtk_timeout_remove(html->tooltip_timer);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1550 if (html->tooltip_window)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1551 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1552 gtk_widget_destroy(html->tooltip_window);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1553 html->tooltip_window = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1554 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1555 html->tooltip_timer =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1556 gtk_timeout_add(HTML_TOOLTIP_DELAY,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1557 gtk_html_tooltip_timeout, html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1558 }
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1559
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1560 cursor = gdk_cursor_new(GDK_HAND2);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1561 gdk_window_set_cursor(html->html_area, cursor);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1562 gdk_cursor_destroy(cursor);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
1563
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1564 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1565 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1566 urls = urls->next;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1567 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1568 if (html->tooltip_timer != -1)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1569 gtk_timeout_remove(html->tooltip_timer);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1570 if (html->tooltip_window)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1571 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1572 gtk_widget_destroy(html->tooltip_window);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1573 html->tooltip_window = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1574 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1575
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1576
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1577 html->tooltip_hb = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1578 gdk_window_set_cursor(html->html_area, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1579
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1580
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1581 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1582
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1583 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1584 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1585
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1586 static gint gtk_html_button_release(GtkWidget * widget, GdkEventButton * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1587 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1588 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1589
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1590 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1591
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1592 if (html->frozen > 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1593 return TRUE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1594
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1595 if (event->button == 1)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1596 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1597 int realx,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1598 realy;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1599 GtkHtmlBit *hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1600 GList *urls = html->urls;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1601
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1602 realx = event->x;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1603 realy = event->y + html->yoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1604 if (realx != html->start_sel_x || realy != html->start_sel_y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1605 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1606 if (gtk_selection_owner_set(widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1607 GDK_SELECTION_PRIMARY, event->time))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1608 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1609 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1610 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1611 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1612 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1613 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1614 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1615 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1616 if (gdk_selection_owner_get(GDK_SELECTION_PRIMARY) ==
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1617 widget->window)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1618 gtk_selection_owner_set(NULL, GDK_SELECTION_PRIMARY,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1619 event->time);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1620
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1621
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1622 while (urls)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1623 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1624 void open_url_nw(GtkWidget * w, char *url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1625 hb = (GtkHtmlBit *) urls->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1626 if ((realx > hb->x && realx < (hb->x + hb->width)) &&
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1627 (realy < hb->y && realy > (hb->y - hb->height)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1628 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1629 open_url_nw(NULL, hb->url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1630 // else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1631 // open_url(NULL, hb->url);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1632 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1633 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1634 urls = urls->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1635 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1636 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1637 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1638 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1639 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1640
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1641
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1642
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1643 static gint gtk_html_button_press(GtkWidget * widget, GdkEventButton * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1644 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1645 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1646 gfloat value;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1647
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1648
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1649 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1650 value = html->vadj->value;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1651
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1652 if (html->frozen > 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1653 return TRUE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1654
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1655 if (event->button == 4)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1656 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1657 value -= html->vadj->step_increment;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1658 if (value < html->vadj->lower)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1659 value = html->vadj->lower;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1660 gtk_adjustment_set_value(html->vadj, value);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1661 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1662 else if (event->button == 5)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1663 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1664 value += html->vadj->step_increment;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1665 if (value > html->vadj->upper)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1666 value = html->vadj->upper;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1667 gtk_adjustment_set_value(html->vadj, value);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1668
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1669 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1670 else if (event->button == 1)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1671 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1672 GList *hbits = g_list_last(html->html_bits);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1673 int realx,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1674 realy;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1675 GtkHtmlBit *hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1676
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1677 realx = event->x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1678 realy = event->y + html->yoffset;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1679
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1680 html->start_sel_x = realx;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1681 html->start_sel_y = realy;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1682
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1683 if (!hbits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1684 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1685
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1686 if (html->selected_text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1687 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1688 g_free(html->selected_text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1689 html->selected_text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1690 html->start_sel = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1691 html->end_sel = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1692 html->num_start = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1693 html->num_end = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1694 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1695 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1696 hb = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1697 if (hb->was_selected)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1698 gtk_html_draw_bit(html, hb, 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1699 hbits = hbits->prev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1700 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1701 hbits = g_list_last(html->html_bits);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1702 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1703
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1704 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1705 if (realy > hb->y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1706 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1707 if (hb->text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1708 html->num_start = strlen(hb->text) - 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1709 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1710 html->num_start = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1711 html->start_sel = hb;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1712 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1713 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1714 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1715 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1716 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1717 if ((realy < hb->y && realy > (hb->y - hb->height)) &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1718 (realx > hb->x + hb->width))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1719 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1720 if (hb->type != HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1721 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1722 html->num_end = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1723 html->end_sel = hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1724 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1725 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1726
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1727 if (hb->text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1728 html->num_start = strlen(hb->text) - 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1729 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1730 html->num_start = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1731
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1732 html->start_sel = hb;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1733 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1734 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1735 else if ((realx > hb->x && realx < (hb->x + hb->width)) &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1736 (realy < hb->y && realy > (hb->y - hb->height)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1737 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1738 int i,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1739 len;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1740 int w = realx - hb->x;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1741
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1742 if (hb->type != HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1743 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1744 html->num_end = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1745 html->end_sel = hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1746 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1747 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1748
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1749 if (hb->text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1750 len = strlen(hb->text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1751 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1752 len = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1753
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1754 for (i = 1; i <= len; i++)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1755 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1756 if (gdk_text_measure(hb->font, hb->text, i) > w)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1757 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1758 html->num_start = i - 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1759 html->start_sel = hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1760 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1761 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1762 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1763 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1764 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1765 hbits = hbits->prev;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1766 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1767 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1768 else if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1769 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1770 GtkHtmlBit *hb = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1771 int realx,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1772 realy;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1773 GList *urls;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1774
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1775 realx = event->x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1776 realy = event->y + html->yoffset;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1777
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1778 urls = html->urls;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1779 while (urls)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1780 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1781 hb = (GtkHtmlBit *) urls->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1782 if ((realx > hb->x && realx < (hb->x + hb->width)) &&
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1783 (realy < hb->y && realy > (hb->y - hb->height)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1784 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1785 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1786 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1787 urls = urls->next;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1788 hb = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1789 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1790
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1791 if (hb != NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1792 {
69
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1793
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1794 GtkWidget *menu, *button;
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1795
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1796 menu = gtk_menu_new();
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1797
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1798 if (web_browser == BROWSER_NETSCAPE) {
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1799
353
a4df8f1cc61a [gaim-migrate @ 363]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
1800 button = gtk_menu_item_new_with_label(_("Open URL in existing window"));
69
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1801 gtk_signal_connect(GTK_OBJECT(button), "activate",
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1802 GTK_SIGNAL_FUNC(open_url), hb->url);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1803 gtk_menu_append(GTK_MENU(menu), button);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1804 gtk_widget_show(button);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1805
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1806 }
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1807
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1808
353
a4df8f1cc61a [gaim-migrate @ 363]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
1809 button = gtk_menu_item_new_with_label(_("Open URL in new window"));
69
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1810 gtk_signal_connect(GTK_OBJECT(button), "activate",
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1811 GTK_SIGNAL_FUNC(open_url_nw), hb->url);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1812 gtk_menu_append(GTK_MENU(menu), button);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1813 gtk_widget_show(button);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1814
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1815 if (web_browser == BROWSER_NETSCAPE) {
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1816
353
a4df8f1cc61a [gaim-migrate @ 363]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
1817 button = gtk_menu_item_new_with_label(_("Add URL as bookmark"));
69
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1818 gtk_signal_connect(GTK_OBJECT(button), "activate",
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1819 GTK_SIGNAL_FUNC(add_bookmark), hb->url);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1820 gtk_menu_append(GTK_MENU(menu), button);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1821 gtk_widget_show(button);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1822
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1823 }
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1824
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1825 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1826 event->button, event->time);
3b479e2700c9 [gaim-migrate @ 79]
Rob Flynn <gaim@robflynn.com>
parents: 53
diff changeset
1827
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1828 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1829 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1830
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1831 return TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1832 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1833
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1834
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1835 static void gtk_html_draw_bit(GtkHtml * html, GtkHtmlBit * hb, int redraw)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1836 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1837 int mypos,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1838 epos,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1839 spos;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1840 GdkGC *gc = html->gc;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1841 int shift;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1842 GtkStateType selected_state;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1843 GtkWidget *widget = GTK_WIDGET(html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1844 GdkRectangle area;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1845
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1846 if (html->frozen > 0)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1847 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1848
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1849 if (hb->type == HTML_BIT_TEXT)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1850 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1851
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1852 if (!strlen(hb->text))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1853 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1854
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1855 mypos = g_list_index(html->html_bits, hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1856 epos = g_list_index(html->html_bits, html->end_sel);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1857 spos = g_list_index(html->html_bits, html->start_sel);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1858
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1859 if (((html->end_sel == NULL) || (html->start_sel == NULL)) ||
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1860 ((epos < mypos) && (spos < mypos)) ||
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1861 ((epos > mypos) && (spos > mypos)))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1862 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1863 selected_state = GTK_STATE_NORMAL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1864 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1865 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1866 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1867 selected_state = GTK_STATE_SELECTED;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1868 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1869
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1870
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1871 gdk_text_extents(hb->font, hb->text, 1, &shift, NULL, NULL, NULL, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1872
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1873 if (selected_state == GTK_STATE_SELECTED)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1874 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1875 int schar = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1876 echar = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1877 int startx = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1878 xwidth = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1879
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1880 if (epos > spos ||
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1881 (epos == spos && html->num_end >= html->num_start))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1882 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1883 if (mypos == epos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1884 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1885 echar = html->num_end;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1886 xwidth =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1887 gdk_text_width(hb->font, hb->text, html->num_end + 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1888 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1889 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1890 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1891 echar = strlen(hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1892 xwidth = hb->width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1893 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1894 if (mypos == spos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1895 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1896 schar = html->num_start;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1897 startx =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1898 gdk_text_width(hb->font, hb->text, html->num_start);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1899 xwidth -= startx;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1900 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1901 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1902 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1903 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1904 if (mypos == spos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1905 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1906 echar = html->num_start;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1907 xwidth =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1908 gdk_text_width(hb->font, hb->text,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1909 html->num_start + 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1910 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1911 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1912 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1913 echar = strlen(hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1914 xwidth = hb->width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1915 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1916 if (mypos == epos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1917 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1918 schar = html->num_end;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1919 startx =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1920 gdk_text_width(hb->font, hb->text, html->num_end);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1921 xwidth -= startx;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1922 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1923 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1924
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1925 if (!redraw && echar == hb->sel_e && schar == hb->sel_s)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1926 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1927
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1928 hb->sel_e = echar;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1929 hb->sel_s = schar;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1930
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1931 startx += hb->x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1932
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1933
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1934 area.x = hb->x - html->xoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1935 area.y = hb->y - hb->height + 3 - html->yoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1936 area.width = hb->width + 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1937 area.height = hb->height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1938 clear_area(html, &area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1939
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1940 gtk_paint_flat_box(widget->style, html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1941 selected_state, GTK_SHADOW_NONE,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1942 NULL, widget, "text",
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1943 startx,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1944 hb->y - hb->height + 3 - html->yoffset,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1945 xwidth + 2, hb->height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1946 hb->was_selected = 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1947 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1948 else if (hb->was_selected)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1949 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1950 area.x = hb->x - html->xoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1951 area.y = hb->y - hb->height + 3 - html->yoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1952 area.width = hb->width + 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1953 area.height = hb->height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1954 clear_area(html, &area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1955
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1956 hb->sel_e = -1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1957 hb->sel_s = -1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1958
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1959 hb->was_selected = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1960 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1961
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1962
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1963
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1964
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1965 if (selected_state == GTK_STATE_SELECTED && (mypos == epos
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1966 || mypos == spos))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1967 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1968 char *s = hb->text;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1969 int num = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1970 width = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1971 fsel = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1972 esel = strlen(hb->text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1973 int lbearing,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1974 rbearing,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1975 w;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1976
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1977 if (epos > spos ||
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1978 (epos == spos && html->num_end >= html->num_start))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1979 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1980 if (mypos == epos)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1981 esel = html->num_end;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1982 if (mypos == spos)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1983 fsel = html->num_start;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1984 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1985 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1986 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1987 if (mypos == spos)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1988 esel = html->num_start;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1989 if (mypos == epos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1990 fsel = html->num_end;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1991 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1992
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1993 while (*s)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1994 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1995
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1996 if (num < fsel || num > esel)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1997 selected_state = GTK_STATE_NORMAL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1998 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1999 selected_state = GTK_STATE_SELECTED;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2000 if (hb->fore != NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2001 gdk_gc_set_foreground(gc, hb->fore);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2002 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2003 gdk_gc_set_foreground(gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2004 &widget->style->fg[selected_state]);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2005 if (hb->back != NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2006 gdk_gc_set_background(gc, hb->back);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2007 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2008 gdk_gc_set_background(gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2009 &widget->style->bg[selected_state]);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2010
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2011
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2012 gdk_gc_set_font(gc, hb->font);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2013
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2014 gdk_text_extents(hb->font, s, 1, &lbearing, &rbearing, &w, NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2015 NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2016
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2017 gdk_draw_text(html->html_area, hb->font, gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2018 shift + hb->x + width, hb->y - html->yoffset, s,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2019 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2020
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2021 if (hb->uline)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2022 gdk_draw_line(html->html_area, gc, shift + hb->x + width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2023 hb->y - html->yoffset,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2024 shift + hb->x + width + w,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2025 hb->y - html->yoffset);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2026
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2027 if (hb->strike)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2028 gdk_draw_line(html->html_area, gc, shift + hb->x + width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2029 hb->y - html->yoffset - (hb->height / 3),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2030 shift + hb->x + width + w,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2031 hb->y - html->yoffset - (hb->height / 3));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2032
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2033 width += w;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2034
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2035 s++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2036 num++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2037 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2038
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2039
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2040 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2041 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2042 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2043 /*my stuff here*/
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2044
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2045 if(!hb->was_selected)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2046 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2047 area.x = hb->x - html->xoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2048 area.y = hb->y - hb->height + 3 - html->yoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2049 area.width = hb->width + 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2050 area.height = hb->height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2051 clear_area(html, &area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2052 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2053
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2054 /*end my stuff*/
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2055
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2056
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2057 if (hb->fore != NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2058 gdk_gc_set_foreground(gc, hb->fore);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2059 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2060 gdk_gc_set_foreground(gc, &widget->style->fg[selected_state]);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2061 if (hb->back != NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2062 gdk_gc_set_background(gc, hb->back);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2063 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2064 gdk_gc_set_background(gc, &widget->style->bg[selected_state]);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2065
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2066
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2067 gdk_gc_set_font(gc, hb->font);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2068
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2069
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2070 gdk_draw_string(html->html_area, hb->font, gc, shift + hb->x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2071 hb->y - html->yoffset, hb->text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2072 if (hb->uline)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2073 gdk_draw_line(html->html_area, gc, shift + hb->x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2074 hb->y - html->yoffset,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2075 hb->x + gdk_string_measure(hb->font, hb->text),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2076 hb->y - html->yoffset);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2077
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2078 if (hb->strike)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2079 gdk_draw_line(html->html_area, gc, shift + hb->x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2080 hb->y - html->yoffset - (hb->height / 3),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2081 hb->x + gdk_string_measure(hb->font, hb->text),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2082 hb->y - html->yoffset - (hb->height / 3));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2083
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2084 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2085 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2086 else if (hb->type == HTML_BIT_SEP)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2087 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2088
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2089 gdk_draw_line(html->html_area, gc, hb->x + 2,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2090 hb->y - html->yoffset - (hb->height / 2 - 1),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2091 hb->x + hb->width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2092 hb->y - html->yoffset - (hb->height / 2 - 1));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2093
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2094 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2095 else if (hb->type == HTML_BIT_PIXMAP)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2096 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2097 gdk_gc_set_background(gc, &widget->style->base[GTK_STATE_NORMAL]);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2098 gdk_draw_pixmap(html->html_area, gc, hb->pm, 0, 0, hb->x,
492
56399273ed8d [gaim-migrate @ 502]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 481
diff changeset
2099 hb->y - html->yoffset - (hb->height) + 4, -1, -1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2100 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2101 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2102
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2103
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2104
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2105 gint compare_types(GtkHtmlBit * hb, GtkHtmlBit * hb2)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2106 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2107 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2108 * In this function, it's OK to accidently return a
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2109 * * 0, but will cause problems on an accidental 1
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2110 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2111
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2112 if (!hb || !hb2)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2113 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2114
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2115
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2116 if (hb->uline != hb2->uline)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2117 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2118 if (hb->strike != hb2->strike)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2119 return 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2120 if (hb->font && hb2->font)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2121 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2122 if (!gdk_font_equal(hb->font, hb2->font))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2123 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2124 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2125 else if (hb->font && !hb2->font)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2126 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2127 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2128 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2129 else if (!hb->font && hb2->font)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2130 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2131 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2132 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2133 if (hb->type != hb2->type)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2134 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2135
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2136 if (hb->fore && hb2->fore)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2137 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2138 if (!gdk_color_equal(hb->fore, hb2->fore))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2139 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2140 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2141 else if (hb->fore && !hb2->fore)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2142 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2143 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2144 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2145 else if (!hb->fore && hb2->fore)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2146 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2147 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2148 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2149
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2150 if (hb->back && hb2->back)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2151 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2152 if (!gdk_color_equal(hb->back, hb2->back))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2153 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2154 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2155 else if (hb->back && !hb2->back)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2156 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2157 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2158 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2159 else if (!hb->back && hb2->back)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2160 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2161 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2162 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2163
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2164 if ((hb->url != NULL && hb2->url == NULL) ||
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2165 (hb->url == NULL && hb2->url != NULL))
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2166 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2167
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2168 if (hb->url != NULL && hb2->url != NULL)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2169 if (strcasecmp(hb->url, hb2->url))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2170 return 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2171
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2172 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2173 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2174
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2175 static gint html_bit_is_onscreen(GtkHtml * html, GtkHtmlBit * hb)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2176 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2177 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2178 height;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2179
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2180 gdk_window_get_size(html->html_area, &width, &height);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2181
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2182 if (hb->y < html->yoffset)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2183 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2184 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2185 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2186
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2187 if ((hb->y - hb->height) > (html->yoffset + height))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2188 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2189 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2190 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2191 return 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2192 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2193
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2194 static void draw_cursor(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2195 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2196 if (html->editable &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2197 html->cursor_hb &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2198 GTK_WIDGET_DRAWABLE(html) &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2199 html_bit_is_onscreen(html, html->cursor_hb))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2200 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2201 gint x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2202 y;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2203 gint width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2204
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2205 GdkFont *font = html->cursor_hb->font;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2206
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2207 gdk_text_extents(font, html->cursor_hb->text, html->cursor_pos, NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2208 NULL, &width, NULL, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2209
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2210 gdk_gc_set_foreground(html->gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2211 &GTK_WIDGET(html)->style->text[GTK_STATE_NORMAL]);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2212
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2213 y = html->cursor_hb->y - html->yoffset;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2214 x = html->cursor_hb->x + width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2215
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2216
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2217 gdk_draw_line(html->html_area, html->gc, x, y, x, y - font->ascent);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2218
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2219 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2220 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2221
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2222 static void undraw_cursor(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2223 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2224 if (html->editable &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2225 html->cursor_hb &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2226 GTK_WIDGET_DRAWABLE(html) &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2227 html_bit_is_onscreen(html, html->cursor_hb))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2228 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2229 gint x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2230 y;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2231 gint width;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2232 GdkRectangle area;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2233
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2234 GdkFont *font = html->cursor_hb->font;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2235
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2236 gdk_text_extents(font, html->cursor_hb->text, html->cursor_pos, NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2237 NULL, &width, NULL, NULL);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2238
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2239 y = html->cursor_hb->y - html->yoffset;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2240 x = html->cursor_hb->x + width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2241
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2242 area.x = x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2243 area.y = y - font->ascent;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2244 area.height = font->ascent + 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2245 area.width = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2246
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2247
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2248 clear_area(html, &area);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2249
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2250 gtk_html_draw_bit(html, html->cursor_hb, 1);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2251
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2252
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2253 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2254 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2255
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2256
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2257 static void expose_html(GtkHtml * html, GdkRectangle * area, gboolean cursor)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2258 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2259 GList *hbits;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2260 GtkHtmlBit *hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2261 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2262 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2263 gint realy;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2264
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2265
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2266 if (html->frozen > 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2267 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2268
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2269
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2270 hbits = html->html_bits;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2271
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2272 gdk_window_get_size(html->html_area, &width, &height);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2273
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2274 realy = area->y + html->yoffset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2275
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2276 clear_area(html, area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2277
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2278 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2279 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2280
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2281 hb = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2282
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2283 if (html_bit_is_onscreen(html, hb))
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2284 gtk_html_draw_bit(html, hb, 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2285
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2286
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2287 hbits = hbits->next;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2288 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2289 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2290
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2291 static void resize_html(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2292 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2293 GList *hbits = html->html_bits;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2294 GList *html_bits = html->html_bits;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2295 GtkHtmlBit *hb,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2296 *hb2;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2297 char *str;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2298 gint height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2299
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2300 if (!hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2301 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2302
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2303
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2304 html->html_bits = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2305
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2306 html->current_x = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2307 html->current_y = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2308
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2309 html->vadj->upper = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2310
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2311 gtk_html_freeze(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2312
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2313 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2314 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2315 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2316 if (hb->type == HTML_BIT_SEP)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2317 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2318
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2319 gtk_html_add_seperator(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2320
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2321 g_free(hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2322
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2323 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2324 continue;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2325 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2326 if (hb->type == HTML_BIT_PIXMAP)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2327 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2328
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2329 gtk_html_add_pixmap(html, hb->pm, hb->fit);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2330
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2331 g_free(hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2332
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2333 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2334 continue;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2335 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2336
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2337 if (hb->newline)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2338 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2339 int i;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2340
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2341 if (!hb->text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2342 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2343 hb->text = g_malloc(1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2344 hb->text[0] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2345 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2346 for (i = 0; i < hb->newline; i++)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2347 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2348 str = hb->text;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2349 hb->text = g_strconcat(str, "\n", NULL);
506
58af37870fdd [gaim-migrate @ 516]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 499
diff changeset
2350 if (str) g_free(str);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2351 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2352 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2353
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2354 if (hbits->next)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2355 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2356 hb2 = (GtkHtmlBit *) hbits->next->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2357 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2358 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2359 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2360 hb2 = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2361 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2362
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2363
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2364
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2365 if (!hb->newline && compare_types(hb, hb2))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2366 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2367 str = hb2->text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2368 hb2->text = g_strconcat(hb->text, hb2->text, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2369 g_free(str);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2370 hb2 = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2371 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2372 else if (hb->text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2373 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2374 gtk_html_add_text(html, hb->font, hb->fore, hb->back,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2375 hb->text, strlen(hb->text), hb->uline, hb->strike,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2376 hb->url);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2377 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2378
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2379
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2380
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2381 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2382 * Font stays, so do colors (segfaults if I free)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2383 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2384 if (hb->fore)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2385 gdk_color_free(hb->fore);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2386 if (hb->back)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2387 gdk_color_free(hb->back);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2388 if (hb->text)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2389 g_free(hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2390 if (hb->url)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2391 g_free(hb->url);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2392
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2393 g_free(hb);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2394
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2395 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2396 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2397
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2398 g_list_free(html_bits);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2399
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2400
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2401 gtk_html_thaw(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2402
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2403 gdk_window_get_size(html->html_area, NULL, &height);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2404 gtk_adjustment_set_value(html->vadj, html->vadj->upper - height);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2405
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2406 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2407
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2408 static GdkGC *create_bg_gc(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2409 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2410 GdkGCValues values;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2411
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2412 values.tile = GTK_WIDGET(html)->style->bg_pixmap[GTK_STATE_NORMAL];
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2413 values.fill = GDK_TILED;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2414
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2415 return gdk_gc_new_with_values(html->html_area, &values,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2416 GDK_GC_FILL | GDK_GC_TILE);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2417 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2418
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2419 static void clear_area(GtkHtml * html, GdkRectangle * area)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2420 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2421 GtkWidget *widget = GTK_WIDGET(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2422 gint x,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2423 y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2424
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2425
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2426 if (html->transparent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2427 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2428 if (html->pm == NULL)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2429 html->pm = get_desktop_pixmap(widget);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2430
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2431 if (html->pm == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2432 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2433
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2434 if (html->bg_gc == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2435 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2436 GdkGCValues values;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2437
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2438 values.tile = html->pm;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2439 values.fill = GDK_TILED;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2440
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2441 html->bg_gc = gdk_gc_new_with_values(html->html_area, &values,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2442 GDK_GC_FILL | GDK_GC_TILE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2443
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2444 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2445
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2446 gdk_window_get_deskrelative_origin(html->html_area, &x, &y);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2447
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2448 gdk_draw_pixmap(html->html_area, html->bg_gc, html->pm,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2449 x + area->x, y + area->y, area->x, area->y, area->width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2450 area->height);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2451
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2452 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2453
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2454 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2455 if (html->bg_gc)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2456 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2457
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2458 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2459 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2460
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2461 gdk_window_get_size(widget->style->bg_pixmap[GTK_STATE_NORMAL], &width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2462 &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2463
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2464 gdk_gc_set_ts_origin(html->bg_gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2465 (-html->xoffset) % width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2466 (-html->yoffset) % height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2467
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2468 gdk_draw_rectangle(html->html_area, html->bg_gc, TRUE,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2469 area->x, area->y, area->width, area->height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2470 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2471 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2472 gdk_window_clear_area(html->html_area, area->x, area->y, area->width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2473 area->height);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2474 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2475
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2476
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2477
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2478
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2479 static void gtk_html_destroy(GtkObject * object)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2480 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2481 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2482
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2483 g_return_if_fail(object != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2484 g_return_if_fail(GTK_IS_HTML(object));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2485
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2486 html = (GtkHtml *) object;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2487
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2488
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2489 gtk_signal_disconnect_by_data(GTK_OBJECT(html->hadj), html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2490 gtk_signal_disconnect_by_data(GTK_OBJECT(html->vadj), html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2491
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2492 if (html->timer)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2493 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2494 gtk_timeout_remove(html->timer);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2495 html->timer = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2496 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2497
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2498 if (html->tooltip_timer)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2499 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2500 gtk_timeout_remove(html->tooltip_timer);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2501 html->tooltip_timer = -1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2502 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2503
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2504
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2505 GTK_OBJECT_CLASS(parent_class)->destroy(object);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2506
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2507 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2508
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2509 static void gtk_html_finalize(GtkObject * object)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2510 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2511 GList *hbits;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2512 GtkHtml *html;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2513 GtkHtmlBit *hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2514
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2515
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2516 g_return_if_fail(object != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2517 g_return_if_fail(GTK_IS_HTML(object));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2518
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2519 html = (GtkHtml *) object;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2520
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2521 gtk_object_unref(GTK_OBJECT(html->hadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2522 gtk_object_unref(GTK_OBJECT(html->vadj));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2523
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2524 hbits = html->html_bits;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2525
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2526 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2527 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2528 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2529 if (hb->fore)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2530 gdk_color_free(hb->fore);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2531 if (hb->back)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2532 gdk_color_free(hb->back);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2533 if (hb->text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2534 g_free(hb->text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2535 if (hb->url)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2536 g_free(hb->url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2537 if (hb->pm)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2538 gdk_pixmap_unref(hb->pm);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2539
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2540 g_free(hb);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2541 hbits = hbits->next;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2542 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2543 if (html->html_bits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2544 g_list_free(html->html_bits);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2545
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2546 if (html->urls)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2547 g_list_free(html->urls);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2548
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2549 if (html->selected_text)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2550 g_free(html->selected_text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2551
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2552 if (html->gc)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2553 gdk_gc_destroy(html->gc);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2554
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2555 if (html->bg_gc)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2556 gdk_gc_destroy(html->bg_gc);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2557
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2558 if (html->tooltip_window)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2559 gtk_widget_destroy(html->tooltip_window);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2560
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2561 GTK_OBJECT_CLASS(parent_class)->finalize(object);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2562 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2563
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2564 static void gtk_html_realize(GtkWidget * widget)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2565 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2566 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2567 GdkWindowAttr attributes;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2568 gint attributes_mask;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2569
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2570 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2571 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2572
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2573 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2574 GTK_WIDGET_SET_FLAGS(html, GTK_REALIZED);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2575
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2576 attributes.window_type = GDK_WINDOW_CHILD;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2577 attributes.x = widget->allocation.x;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2578 attributes.y = widget->allocation.y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2579 attributes.width = widget->allocation.width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2580 attributes.height = widget->allocation.height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2581 attributes.wclass = GDK_INPUT_OUTPUT;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2582 attributes.visual = gtk_widget_get_visual(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2583 attributes.colormap = gtk_widget_get_colormap(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2584 attributes.event_mask = gtk_widget_get_events(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2585 attributes.event_mask |= (GDK_EXPOSURE_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2586 GDK_BUTTON_PRESS_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2587 GDK_BUTTON_RELEASE_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2588 GDK_BUTTON_MOTION_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2589 GDK_ENTER_NOTIFY_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2590 GDK_LEAVE_NOTIFY_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2591 GDK_POINTER_MOTION_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2592 GDK_POINTER_MOTION_HINT_MASK |
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2593 GDK_VISIBILITY_NOTIFY_MASK | GDK_KEY_PRESS_MASK);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2594
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2595 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2596
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2597 widget->window =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2598 gdk_window_new(gtk_widget_get_parent_window(widget), &attributes,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2599 attributes_mask);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2600 gdk_window_set_user_data(widget->window, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2601
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2602 attributes.x = (widget->style->klass->xthickness + BORDER_WIDTH);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2603 attributes.y = (widget->style->klass->ythickness + BORDER_WIDTH);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2604 attributes.width =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2605 MAX(1, (gint) widget->allocation.width - (gint) attributes.x * 2);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2606 attributes.height =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2607 MAX(1, (gint) widget->allocation.height - (gint) attributes.y * 2);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2608
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2609 html->html_area =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2610 gdk_window_new(widget->window, &attributes, attributes_mask);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2611 gdk_window_set_user_data(html->html_area, html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2612
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2613 widget->style = gtk_style_attach(widget->style, widget->window);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2614
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2615 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2616 * Can't call gtk_style_set_background here because it's handled specially
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2617 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2618 gdk_window_set_background(widget->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2619 &widget->style->base[GTK_STATE_NORMAL]);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2620 gdk_window_set_background(html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2621 &widget->style->base[GTK_STATE_NORMAL]);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2622
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2623 if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2624 html->bg_gc = create_bg_gc(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2625
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2626 html->gc = gdk_gc_new(html->html_area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2627 gdk_gc_set_exposures(html->gc, TRUE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2628 gdk_gc_set_foreground(html->gc, &widget->style->text[GTK_STATE_NORMAL]);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2629
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2630 gdk_window_show(html->html_area);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2631
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2632 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2633
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2634 static void gtk_html_style_set(GtkWidget * widget, GtkStyle * previous_style)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2635 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2636 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2637
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2638 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2639 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2640
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2641 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2642 if (GTK_WIDGET_REALIZED(widget))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2643 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2644 gdk_window_set_background(widget->window,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2645 &widget->style->base[GTK_STATE_NORMAL]);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2646 gdk_window_set_background(html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2647 &widget->style->base[GTK_STATE_NORMAL]);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2648
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2649 if (html->bg_gc)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2650 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2651 gdk_gc_destroy(html->bg_gc);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2652 html->bg_gc = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2653 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2654
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2655 if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2656 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2657 html->bg_gc = create_bg_gc(html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2658 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2659
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2660 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2661 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2662
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2663 static void gtk_html_unrealize(GtkWidget * widget)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2664 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2665 GtkHtml *html;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2666
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2667 g_return_if_fail(widget != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2668 g_return_if_fail(GTK_IS_HTML(widget));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2669
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2670 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2671
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2672 gdk_window_set_user_data(html->html_area, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2673 gdk_window_destroy(html->html_area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2674 html->html_area = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2675
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2676 gdk_gc_destroy(html->gc);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2677 html->gc = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2678
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2679 if (html->bg_gc)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2680 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2681 gdk_gc_destroy(html->bg_gc);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2682 html->bg_gc = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2683 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2684
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2685 if (GTK_WIDGET_CLASS(parent_class)->unrealize)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2686 (*GTK_WIDGET_CLASS(parent_class)->unrealize) (widget);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2687 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2688
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2689
337
f5b199e20d12 [gaim-migrate @ 347]
Rob Flynn <gaim@robflynn.com>
parents: 306
diff changeset
2690 void gtk_html_add_pixmap(GtkHtml * html, GdkPixmap * pm, int fit)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2691 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2692 GtkHtmlBit *last_hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2693 GtkHtmlBit *hb = g_new0(GtkHtmlBit, 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2694 GdkWindowPrivate *private = (GdkWindowPrivate *) pm;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2695
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2696 last_hb = (GtkHtmlBit *) g_list_last(html->html_bits)->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2697
499
3ebd3ca4c3d4 [gaim-migrate @ 509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 492
diff changeset
2698 /* make sure pixmaps drop down a line after a <BR> */
3ebd3ca4c3d4 [gaim-migrate @ 509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 492
diff changeset
2699 if (last_hb->newline)
3ebd3ca4c3d4 [gaim-migrate @ 509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 492
diff changeset
2700 html->current_y += private->height + 2;
3ebd3ca4c3d4 [gaim-migrate @ 509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 492
diff changeset
2701
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2702 hb->fit = fit;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2703 hb->x = html->current_x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2704 hb->y = html->current_y;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2705 if (fit)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2706 hb->height = last_hb->height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2707 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2708 hb->height = private->height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2709 hb->type = HTML_BIT_PIXMAP;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2710 hb->width = private->width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2711 hb->text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2712 hb->url = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2713 hb->fore = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2714 hb->back = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2715 hb->font = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2716 hb->uline = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2717 hb->strike = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2718 hb->was_selected = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2719 hb->newline = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2720 hb->pm = pm;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2721
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2722 if (html->current_x == BORDER_WIDTH)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2723 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2724 html->current_y += hb->height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2725 hb->y += hb->height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2726 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2727
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2728
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2729 html->current_x += hb->width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2730
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2731 gtk_html_draw_bit(html, hb, 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2732
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2733 html->html_bits = g_list_append(html->html_bits, hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2734
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2735
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2736 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2737
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2738 static void gtk_html_add_seperator(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2739 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2740 GtkHtmlBit *hb = g_new0(GtkHtmlBit, 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2741 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2742 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2743
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2744 html->current_x = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2745 html->current_y += 5;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2746
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2747 gdk_window_get_size(html->html_area, &width, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2748
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2749 hb->x = html->current_x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2750 hb->y = html->current_y;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2751 hb->height = 5;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2752 hb->type = HTML_BIT_SEP;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2753 hb->width =
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2754 width -
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2755 GTK_SCROLLED_WINDOW(GTK_WIDGET(html)->parent)->vscrollbar->allocation.
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2756 width - 10;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2757 hb->text = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2758 hb->url = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2759 hb->fore = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2760 hb->back = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2761 hb->font = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2762 hb->uline = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2763 hb->strike = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2764 hb->was_selected = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2765 hb->newline = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2766 hb->pm = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2767
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2768 gtk_html_draw_bit(html, hb, 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2769
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2770 html->html_bits = g_list_append(html->html_bits, hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2771
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2772 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2773
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2774
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2775 static void gtk_html_add_text(GtkHtml * html,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2776 GdkFont * cfont,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2777 GdkColor * fore,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2778 GdkColor * back,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2779 char *chars,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2780 gint length, gint uline, gint strike, char *url)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2781 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2782 char *nextline = NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2783 *c,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2784 *text,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2785 *tmp;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2786 GdkGC *gc;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2787 int nl = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2788 nl2 = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2789 int maxwidth;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2790 gint lb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2791 GList *hbits;
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 69
diff changeset
2792 size_t num = 0;
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 69
diff changeset
2793 int i,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2794 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2795 GtkHtmlBit *hb;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2796 gint hwidth,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2797 hheight;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2798
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2799 if (length == 1 && chars[0] == '\n')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2800 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2801 GtkHtmlBit *h;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2802 hbits = g_list_last(html->html_bits);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2803 if (!hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2804 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2805 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2806 * I realize this loses a \n sometimes
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2807 * * if it's the first thing in the widget.
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2808 * * so fucking what.
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2809 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2810
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2811 h = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2812 h->newline++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2813 if (html->current_x > 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2814 html->current_x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2815 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2816 html->current_y += cfont->ascent + cfont->descent + 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2817 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2818 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2819
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2820
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2821
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2822 c = text = g_malloc(length + 2);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2823 strncpy(text, chars, length);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2824 text[length] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2825
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2826
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2827 gc = html->gc;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2828
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2829 if (gc == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2830 gc = html->gc = gdk_gc_new(html->html_area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2831
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2832 gdk_gc_set_font(gc, cfont);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2833
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2834
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2835 while (*c)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2836 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2837 if (*c == '\n')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2838 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2839 if (*(c + 1) == '\0')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2840 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2841 nl = 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2842 length--;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2843 c[0] = '\0';
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2844 break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2845 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2846 if (*c)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2847 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2848 gtk_html_add_text(html, cfont, fore, back, text, num + 1, uline,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2849 strike, url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2850 tmp = text;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2851 length -= (num + 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2852 text = g_malloc(length + 2);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2853 strncpy(text, (c + 1), length);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2854 text[length] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2855 c = text;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2856 num = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2857 g_free(tmp);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2858 continue;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2859 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2860 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2861
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2862 num++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2863 c++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2864 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2865
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2866 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2867 * Note, yG is chosen because G is damn high, and y is damn low,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2868 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2869 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2870 * it should be just fine. :)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2871 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2872
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2873 gdk_window_get_size(html->html_area, &hwidth, &hheight);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2874
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2875 num = strlen(text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2876
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2877 while (GTK_WIDGET(html)->allocation.width < 20)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2878 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2879 while (gtk_events_pending())
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2880 gtk_main_iteration();
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2881 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2882
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2883 maxwidth = (hwidth - html->current_x - 8);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2884 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2885 * HTK_SCROLLED_WINDOW(GTK_WIDGET(layout)->parent)->vscrollbar->allocation.width) - 8;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2886 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2887
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2888 while (gdk_text_measure(cfont, text, num) > maxwidth)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2889 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2890 if (num > 1)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2891 num--;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2892 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2893 {
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2894 if (html->current_x != 0) {
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2895 html->current_x = 0;
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2896 if (nl) {
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2897 text[length] = '\n';
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2898 length++;
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2899 }
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2900 gtk_html_add_text(html, cfont, fore, back, text, length, uline, strike, url);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2901 g_free(text);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2902 return;
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2903 } else {
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2904 num = strlen (text);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2905 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2906 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2907 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2908
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2909 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2910
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2911 height = cfont->ascent + cfont->descent + 2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2912
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2913
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2914 if ((int) (html->vadj->upper - html->current_y) < (int) (height * 2))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2915 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2916 int val;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2917 val = (height * 2) + html->current_y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2918 html->vadj->upper = val;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2919 adjust_adj(html, html->vadj);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2920 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2921
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2922
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2923 if (html->current_x == 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2924 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2925 html->current_y += height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2926 gdk_text_extents(cfont, text, 1, &lb, NULL, NULL, NULL, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2927 html->current_x += (2 - lb);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2928 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2929 else if ((hbits = g_list_last(html->html_bits)) != NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2930 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2931 int diff,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2932 y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2933 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2934 if (height > hb->height)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2935 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2936 diff = height - hb->height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2937 y = hb->y;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2938 html->current_y += diff;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2939 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2940 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2941 hb = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2942 if (hb->y != y)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2943 break;
492
56399273ed8d [gaim-migrate @ 502]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 481
diff changeset
2944 if (hb->type != HTML_BIT_PIXMAP)
56399273ed8d [gaim-migrate @ 502]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 481
diff changeset
2945 hb->height = height;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2946 hb->y += diff; ////////////my thing here /////////////////
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2947 gtk_html_draw_bit(html, hb, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2948
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2949 hbits = hbits->prev;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2950 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2951 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2952 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2953
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2954
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2955
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2956
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2957 if (num != strlen(text))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2958 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2959 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2960 * This is kinda cheesy but it may make things
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2961 * * much better lookin
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2962 */
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2963
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2964 for (i=2; (num - i > 0); i++) {
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 12
diff changeset
2965 if (text[num - i] == ' ') {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2966 num = num - (i - 1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2967 nl2 = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2968 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2969 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2970 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2971
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2972 nextline = g_malloc(length - num + 2);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2973 strncpy(nextline, (char *) (text + num), length - num);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2974 nextline[length - num] = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2975 if (nl)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2976 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2977 nextline[length - num] = '\n';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2978 nextline[length - num + 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2979 nl = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2980 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2981
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2982
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2983 text[num] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2984 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2985
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2986
52
ceb0d714d180 [gaim-migrate @ 62]
Rob Flynn <gaim@robflynn.com>
parents: 49
diff changeset
2987 if (url != NULL) {
53
bb007396e0a1 [gaim-migrate @ 63]
Rob Flynn <gaim@robflynn.com>
parents: 52
diff changeset
2988 fore = get_color(3355647, gdk_window_get_colormap(html->html_area));
52
ceb0d714d180 [gaim-migrate @ 62]
Rob Flynn <gaim@robflynn.com>
parents: 49
diff changeset
2989 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2990
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2991 hb = g_new0(GtkHtmlBit, 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2992
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2993 hb->text = g_strdup(text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2994
52
ceb0d714d180 [gaim-migrate @ 62]
Rob Flynn <gaim@robflynn.com>
parents: 49
diff changeset
2995 if (fore)
ceb0d714d180 [gaim-migrate @ 62]
Rob Flynn <gaim@robflynn.com>
parents: 49
diff changeset
2996 hb->fore = gdk_color_copy(fore);
ceb0d714d180 [gaim-migrate @ 62]
Rob Flynn <gaim@robflynn.com>
parents: 49
diff changeset
2997 else
ceb0d714d180 [gaim-migrate @ 62]
Rob Flynn <gaim@robflynn.com>
parents: 49
diff changeset
2998 hb->fore = NULL;
49
4d25b98a9d09 [gaim-migrate @ 58]
Jim Duchek <jimduchek>
parents: 26
diff changeset
2999
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3000 if (back)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3001 hb->back = gdk_color_copy(back);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3002 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3003 hb->back = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3004 hb->font = cfont;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3005 hb->uline = uline;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3006 hb->strike = strike;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3007 hb->height = height;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3008 gdk_text_extents(cfont, text, num, &lb, NULL, &hb->width, NULL, NULL);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3009 hb->x = html->current_x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3010 hb->y = html->current_y;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3011 hb->type = HTML_BIT_TEXT;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3012 hb->pm = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3013 if (url != NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3014 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3015 uline = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3016 hb->uline = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3017 hb->url = g_strdup(url);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3018 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3019 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3020 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3021 hb->url = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3022 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3023 html->current_x += hb->width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3024
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3025 html->html_bits = g_list_append(html->html_bits, hb);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3026 if (url != NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3027 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3028 html->urls = g_list_append(html->urls, hb);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3029 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3030
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3031
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3032
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3033 gtk_html_draw_bit(html, hb, 1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3034
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3035 if (nl || nl2)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3036 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3037 if (nl)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3038 hb->newline = 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3039 html->current_x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3040 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3041 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3042 hb->newline = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3043
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3044
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3045 if (nextline != NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3046 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3047 gtk_html_add_text(html, cfont, fore, back, nextline, strlen(nextline),
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3048 uline, strike, url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3049 g_free(nextline);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3050 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3051
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3052 g_free(text);
137
fe81c8b4951d [gaim-migrate @ 147]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
3053 if (url != NULL)
fe81c8b4951d [gaim-migrate @ 147]
Rob Flynn <gaim@robflynn.com>
parents: 79
diff changeset
3054 g_free(fore);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3055 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3056
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3057 static char * html_strtok( char * input, char delim )
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3058 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3059 static char * end;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3060 static char * curr_offset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3061 int i;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3062 int num_quotes=0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3063
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3064 if( input != NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3065 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3066 curr_offset = input;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3067 end = input+strlen(input);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3068 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3069 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3070 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3071 if( curr_offset + strlen(curr_offset) < end )
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3072 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3073 curr_offset += strlen(curr_offset) + 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3074 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3075 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3076 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3077 return NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3078 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3079 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3080 for( i=0; curr_offset+i < end &&
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3081 (curr_offset[i] != delim || num_quotes != 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3082 ; i++ )
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3083 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3084 if( curr_offset[i] == '\"' )
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3085 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3086 num_quotes = (num_quotes+1)%2;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3087 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3088 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3089 curr_offset[i] = '\0';
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3090 return curr_offset;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3091 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3092
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3093
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3094 void gtk_html_append_text(GtkHtml * html, char *text, gint options)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3095 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3096 GdkColormap *map;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3097 GdkFont *cfont;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3098 GdkRectangle area;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3099 char ws[BUF_LONG],
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3100 tag[BUF_LONG],
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3101 *c,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3102 *url = NULL;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3103 gint intag = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3104 wpos = 0,
481
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3105 tpos = 0;
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3106 static gint colorv,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3107 bold = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3108 italic = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3109 fixed = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3110 uline = 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3111 strike = 0,
481
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3112 title = 0,
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3113 height;
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3114 static struct font_state *current = NULL,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3115 *tmp;
481
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3116 static struct font_state def_state = { 3, 0, 0, "", NULL, NULL, NULL };
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3117
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3118 if (text == NULL) {
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3119 while (current->next)
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3120 {
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3121 if (current->ownbg)
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3122 g_free(current->bgcol);
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3123 if (current->owncolor)
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3124 g_free(current->color);
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3125 tmp = current;
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3126 current = current->next;
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3127 g_free(tmp);
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3128 }
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3129 return;
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3130 }
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3131
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
3132 if (!current) current = &def_state;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3133 map = gdk_window_get_colormap(html->html_area);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3134 cfont = getfont(current->font, bold, italic, fixed, current->size);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3135 c = text;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3136
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3137
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3138 while (*c)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3139 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3140 if (*c == '<')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3141 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3142 if (!intag)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3143 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3144 ws[wpos] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3145 if (wpos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3146 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3147 if (title)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3148 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3149 if (html->title)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3150 g_free(html->title);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3151 html->title = g_strdup(ws);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3152 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3153 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3154 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3155 current->bgcol, ws, strlen(ws), uline,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3156 strike, url);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3157 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3158 wpos = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3159 intag = 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3160 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3161 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3162 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3163 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3164 * Assuming you NEVER have nested tags
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3165 * * (and I mean <tag <tag>> by this, not
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3166 * * <tag><tag2></tag2><tag>..
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3167 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3168 tag[tpos] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3169 gtk_html_add_text(html, cfont, current->color, current->bgcol,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3170 "<", 1, 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3171 gtk_html_add_text(html, cfont, current->color, current->bgcol,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3172 tag, strlen(tag), 0, 0, NULL);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3173 tpos = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3174
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3175 tag[0] = *c;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3176 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3177 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3178 else if (*c == '>')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3179 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3180 if (intag)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3181 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3182 tag[tpos] = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3183 if (!strcasecmp(tag, "B"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3184 bold = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3185 else if (!strcasecmp(tag, "STRIKE"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3186 strike = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3187 else if (!strcasecmp(tag, "I"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3188 italic = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3189 else if (!strcasecmp(tag, "U"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3190 uline = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3191 else if (!strcasecmp(tag, "PRE"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3192 fixed = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3193 else if (!strcasecmp(tag, "HR"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3194 gtk_html_add_seperator(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3195 else if (!strcasecmp(tag, "/B"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3196 bold = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3197 else if (!strcasecmp(tag, "/STRIKE"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3198 strike = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3199 else if (!strcasecmp(tag, "/I"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3200 italic = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3201 else if (!strcasecmp(tag, "/U"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3202 uline = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3203 else if (!strcasecmp(tag, "/PRE"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3204 fixed = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3205 else if (!strcasecmp(tag, "TITLE"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3206 title = 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3207 else if (!strcasecmp(tag, "/TITLE"))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3208 title = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3209 else if (!strncasecmp(tag, "IMG", 3))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3210 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3211
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3212 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3213 else if (!strcasecmp(tag, "H3"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3214 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3215 current = push_state(current);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3216 current->size = 4;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3217 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3218 else if (!strcasecmp(tag, "/H3"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3219 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3220 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3221 current->bgcol, "\n", 1, 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3222
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3223 if (current->next)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3224 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3225 if (current->ownbg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3226 g_free(current->bgcol);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3227 if (current->owncolor)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3228 g_free(current->color);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3229 tmp = current;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3230 current = current->next;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3231 g_free(tmp);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3232 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3233 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3234 else if (!strcasecmp(tag, "TABLE"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3235 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3236 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3237 else if (!strcasecmp(tag, "/TABLE"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3238 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3239 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3240 else if (!strcasecmp(tag, "TR"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3241 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3242 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3243 else if (!strcasecmp(tag, "/TR"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3244 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3245 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3246 else if (!strcasecmp(tag, "/TD"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3247 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3248 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3249 else if (!strcasecmp(tag, "TD"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3250 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3251 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3252 current->bgcol, " ", 2, 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3253 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3254 else if (!strncasecmp(tag, "A ", 2))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3255 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3256 char *d;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3257 char *temp = d = g_strdup(tag);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3258 int flag = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3259 strtok(tag, " ");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3260 while ((d = strtok(NULL, " ")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3261 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3262 if (strlen(d) < 7)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3263 break;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3264 if (!strncasecmp(d, "HREF=\"", strlen("HREF=\"")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3265 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3266 d += strlen("HREF=\"");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3267 d[strlen(d) - 1] = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3268 url = g_malloc(strlen(d) + 1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3269 strcpy(url, d);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3270 flag = 1;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3271 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3272 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3273 g_free(temp);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3274 if (!flag)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3275 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3276 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3277 current->bgcol, "<", 1, 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3278 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3279 current->bgcol, tag, strlen(tag), 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3280 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3281 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3282 current->bgcol, ">", 1, 0, 0, NULL);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3283 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3284 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3285 else if (!strcasecmp(tag, "/A"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3286 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3287 if (url)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3288 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3289 g_free(url);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3290 url = NULL;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3291 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3292 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3293 else if (!strncasecmp(tag, "FONT", strlen("FONT")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3294 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3295 char *d;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3296 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3297 * Push a new state onto the stack, based on the old state
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3298 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3299 current = push_state(current);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3300 html_strtok(tag, ' ');
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3301 while ((d = html_strtok(NULL, ' ')))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3302 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3303 if (!strncasecmp(d, "COLOR=", strlen("COLOR=")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3304 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3305 d += strlen("COLOR=");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3306 if (*d == '\"')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3307 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3308 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3309 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3310 if (*d == '#')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3311 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3312 if (d[strlen(d) - 1] == '\"')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3313 d[strlen(d) - 1] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3314 if (sscanf(d, "%x", &colorv)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3315 && !(options & HTML_OPTION_NO_COLOURS))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3316 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3317 current->color = get_color(colorv, map);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3318 current->owncolor = 1;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3319 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3320 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3321 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3322 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3323 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3324 if (!strncasecmp(d, "FACE=", strlen("FACE=")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3325 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3326 d += strlen("FACE=");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3327 if (*d == '\"')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3328 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3329 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3330 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3331 if (d[strlen(d) - 1] == '\"')
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3332 d[strlen(d) - 1] = 0;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3333 strcpy(current->font, d);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3334 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3335 else if (!strncasecmp(d, "BACK=", strlen("BACK=")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3336 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3337 d += strlen("BACK=");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3338 if (*d == '\"')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3339 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3340 if (*d == '#')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3341 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3342 if (d[strlen(d) - 1] == '\"')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3343 d[strlen(d) - 1] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3344 if (sscanf(d, "%x", &colorv)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3345 && !(options & HTML_OPTION_NO_COLOURS))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3346 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3347 current->bgcol = get_color(colorv, map);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3348 current->ownbg = 1;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3349 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3350 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3351 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3352 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3353 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3354 else if (!strncasecmp(d, "SIZE=", strlen("SIZE=")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3355 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3356 d += strlen("SIZE=");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3357 if (*d == '\"')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3358 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3359 if (*d == '+')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3360 d++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3361 if (sscanf(d, "%d", &colorv))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3362 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3363 current->size = colorv;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3364 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3365 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3366 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3367 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3368 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3369 else if (strncasecmp(d, "PTSIZE=", strlen("PTSIZE=")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3370 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3371 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3372 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3373 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3374 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3375 if (!strncasecmp
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3376 (tag, "BODY BGCOLOR", strlen("BODY BGCOLOR")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3377 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3378
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3379 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3380 * Ditch trailing \"
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3381 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3382 tag[strlen(tag) - 1] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3383 if (sscanf(tag + strlen("BODY BGCOLOR=\"#"), "%x", &colorv)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3384 && !(options & HTML_OPTION_NO_COLOURS))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3385 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3386 current->bgcol = get_color(colorv, map);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3387 current->ownbg = 1;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3388 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3389 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3390 else if (!strncasecmp(tag, "/FONT", strlen("/FONT")))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3391 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3392 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3393 * Pop a font state off the list if possible, freeing
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3394 * any resources it used
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3395 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3396 if (current->next)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3397 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3398 if (current->ownbg)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3399 g_free(current->bgcol);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3400 if (current->owncolor)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3401 g_free(current->color);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3402 tmp = current;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3403 current = current->next;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3404 g_free(tmp);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3405 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3406
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3407 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3408 else if (!strcasecmp(tag, "/BODY"))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3409 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3410 if (current->next)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3411 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3412 if (current->ownbg)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3413 g_free(current->bgcol);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3414 if (current->owncolor)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3415 g_free(current->color);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3416 tmp = current;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3417 current = current->next;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3418 g_free(tmp);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3419 } /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3420 * tags we ignore below
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3421 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3422 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3423 else if (!strncasecmp(tag, "BR", 2))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3424 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3425 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3426 current->bgcol, "\n", 1, 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3427 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3428 else if (strncasecmp(tag, "HTML", 4)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3429 && strncasecmp(tag, "/HTML", 5)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3430 && strncasecmp(tag, "BODY", 4)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3431 && strncasecmp(tag, "/BODY", 5)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3432 && strncasecmp(tag, "P", 1)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3433 && strncasecmp(tag, "/P", 2)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3434 && strncasecmp(tag, "HEAD", 4)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3435 && strncasecmp(tag, "/HEAD", 5))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3436 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3437 if (tpos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3438 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3439 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3440 current->bgcol, "<", 1, 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3441 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3442 current->bgcol, tag, strlen(tag), 0,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3443 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3444 gtk_html_add_text(html, cfont, current->color,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3445 current->bgcol, ">", 1, 0, 0, NULL);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3446
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3447 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3448 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3449 cfont = getfont(current->font, bold, italic, fixed, current->size);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3450 tpos = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3451 intag = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3452 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3453 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3454 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3455 ws[wpos++] = *c;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3456 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3457 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3458 else if (!intag && *c == '&')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3459 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3460 if (!strncasecmp(c, "&amp;", 5))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3461 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3462 ws[wpos++] = '&';
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3463 c += 4;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3464 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3465 else if (!strncasecmp(c, "&lt;", 4))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3466 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3467 ws[wpos++] = '<';
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3468 c += 3;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3469 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3470 else if (!strncasecmp(c, "&gt;", 4))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3471 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3472 ws[wpos++] = '>';
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3473 c += 3;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3474 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3475 else if (!strncasecmp(c, "&nbsp;", 6))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3476 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3477 ws[wpos++] = ' ';
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3478 c += 5;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3479 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3480 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3481 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3482 ws[wpos++] = *c;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3483 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3484 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3485 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3486 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3487 if (intag)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3488 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3489 tag[tpos++] = *c;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3490 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3491 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3492 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3493 ws[wpos++] = *c;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3494 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3495 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3496 c++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3497 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3498 ws[wpos] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3499 tag[tpos] = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3500 if (wpos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3501 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3502 gtk_html_add_text(html, cfont, current->color, current->bgcol, ws,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3503 strlen(ws), uline, strike, url);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3504 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3505 if (tpos)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3506 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3507 gtk_html_add_text(html, cfont, current->color, current->bgcol, "<", 1,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3508 0, 0, NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3509 gtk_html_add_text(html, cfont, current->color, current->bgcol, tag,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3510 strlen(tag), 0, 0, NULL);
523
023c3851db0a [gaim-migrate @ 533]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 506
diff changeset
3511 /* gtk_html_add_text(html, cfont, current->color, current->bgcol, ">", 1,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3512 0, 0, NULL);
523
023c3851db0a [gaim-migrate @ 533]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 506
diff changeset
3513 */ }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3514
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3515
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3516
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3517 gdk_window_get_size(html->html_area, NULL, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3518 area.height = height;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3519 gtk_adjustment_set_value(html->vadj, html->vadj->upper - area.height);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3520
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3521 return;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3522 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3523
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3524
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3525 static void adjust_adj(GtkHtml * html, GtkAdjustment * adj)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3526 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3527 gint height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3528
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3529 gdk_window_get_size(html->html_area, NULL, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3530
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3531 adj->step_increment = MIN(adj->upper, (float) SCROLL_PIXELS);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3532 adj->page_increment = MIN(adj->upper, height - (float) KEY_SCROLL_PIXELS);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3533 adj->page_size = MIN(adj->upper, height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3534 adj->value = MIN(adj->value, adj->upper - adj->page_size);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3535 adj->value = MAX(adj->value, 0.0);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3536
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3537 gtk_signal_emit_by_name(GTK_OBJECT(adj), "changed");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3538 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3539
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3540
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3541 static void scroll_down(GtkHtml * html, gint diff0)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3542 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3543 GdkRectangle rect;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3544 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3545 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3546
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3547 html->yoffset += diff0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3548
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3549 gdk_window_get_size(html->html_area, &width, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3550
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3551 if (html->transparent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3552 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3553 rect.x = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3554 rect.y = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3555 rect.width = width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3556 rect.height = height;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3557 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3558 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3559 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3560
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3561
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3562 if (height > diff0 && !html->transparent)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3563 gdk_draw_pixmap(html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3564 html->gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3565 html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3566 0, diff0, 0, 0, width, height - diff0);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3567
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3568 rect.x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3569 rect.y = MAX(0, height - diff0);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3570 rect.width = width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3571 rect.height = MIN(height, diff0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3572 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3573
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3574 expose_html(html, &rect, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3575 gtk_html_draw_focus((GtkWidget *) html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3576
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3577 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3578
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3579 static void scroll_up(GtkHtml * html, gint diff0)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3580 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3581 GdkRectangle rect;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3582 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3583 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3584
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3585 html->yoffset -= diff0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3586
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3587
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3588 gdk_window_get_size(html->html_area, &width, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3589
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3590 if (html->transparent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3591 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3592 rect.x = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3593 rect.y = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3594 rect.width = width;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3595 rect.height = height;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3596 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3597 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3598 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3599
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3600 if (height > diff0)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3601 gdk_draw_pixmap(html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3602 html->gc,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3603 html->html_area,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3604 0, 0, 0, diff0, width, height - diff0);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3605
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3606 rect.x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3607 rect.y = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3608 rect.width = width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3609 rect.height = MIN(height, diff0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3610 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3611
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3612 expose_html(html, &rect, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3613 gtk_html_draw_focus((GtkWidget *) html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3614
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3615 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3616
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3617
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3618
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3619 static void gtk_html_adjustment(GtkAdjustment * adjustment, GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3620 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3621 g_return_if_fail(adjustment != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3622 g_return_if_fail(GTK_IS_ADJUSTMENT(adjustment));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3623 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3624 g_return_if_fail(GTK_IS_HTML(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3625
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3626 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3627 * Just ignore it if we haven't been size-allocated and realized yet
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3628 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3629 if (html->html_area == NULL)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3630 return;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3631
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3632 if (adjustment == html->hadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3633 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3634 g_warning("horizontal scrolling not implemented");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3635 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3636 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3637 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3638 gint diff = ((gint) adjustment->value) - html->last_ver_value;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3639
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3640 if (diff != 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3641 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3642 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3643 * undraw_cursor (text, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3644 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3645
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3646 if (diff > 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3647 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3648 scroll_down(html, diff);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3649 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3650 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3651 { /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3652 * if (diff < 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3653 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3654 scroll_up(html, -diff);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3655 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3656 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3657 * draw_cursor (text, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3658 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3659
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3660 html->last_ver_value = adjustment->value;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3661 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3662 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3663 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3664
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3665 static gint gtk_html_visibility_notify(GtkWidget * widget,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3666 GdkEventVisibility * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3667 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3668 GtkHtml *html;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3669 GdkRectangle rect;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3670 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3671 height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3672
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3673 g_return_val_if_fail(widget != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3674 g_return_val_if_fail(GTK_IS_HTML(widget), FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3675
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3676 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3677
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3678 if (GTK_WIDGET_REALIZED(widget) && html->transparent)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3679 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3680 gdk_window_get_size(html->html_area, &width, &height);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3681 rect.x = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3682 rect.y = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3683 rect.width = width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3684 rect.height = height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3685 expose_html(html, &rect, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3686 gtk_html_draw_focus((GtkWidget *) html);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3687 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3688 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3689 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3690 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3691
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3692
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3693 return FALSE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3694 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3695
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3696
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3697
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3698 static void gtk_html_disconnect(GtkAdjustment * adjustment, GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3699 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3700 g_return_if_fail(adjustment != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3701 g_return_if_fail(GTK_IS_ADJUSTMENT(adjustment));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3702 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3703 g_return_if_fail(GTK_IS_HTML(html));
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3704
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3705 if (adjustment == html->hadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3706 gtk_html_set_adjustments(html, NULL, html->vadj);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3707 if (adjustment == html->vadj)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3708 gtk_html_set_adjustments(html, html->hadj, NULL);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3709 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3710
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3711 static void move_cursor_ver(GtkHtml * html, int count)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3712 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3713 GList *hbits = g_list_find(html->html_bits, html->cursor_hb);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3714 GtkHtmlBit *hb = NULL,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3715 *hb2 = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3716 gint y;
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 69
diff changeset
3717 size_t len,
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3718 len2 = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3719
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3720 undraw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3721
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3722 if (!html->html_bits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3723 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3724
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3725 if (!html->cursor_hb)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3726 html->cursor_hb = (GtkHtmlBit *) html->html_bits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3727
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3728 hb = html->cursor_hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3729
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3730 len = html->cursor_pos;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3731 hbits = hbits->prev;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3732 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3733 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3734 hb2 = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3735
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3736 if (hb2->y != hb->y)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3737 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3738
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3739 len += strlen(hb2->text);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3740
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3741 hbits = hbits->prev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3742 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3743
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3744 hbits = g_list_find(html->html_bits, html->cursor_hb);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3745
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3746 if (count < 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3747 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3748 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3749 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3750 hb2 = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3751
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3752 if (hb2->y != hb->y)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3753 break;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3754
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3755 hbits = hbits->prev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3756 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3757 if (!hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3758 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3759 draw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3760 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3761 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3762 y = hb2->y;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3763 hb = hb2;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3764 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3765 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3766 hb2 = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3767
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3768 if (hb2->y != y)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3769 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3770
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3771 hb = hb2;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3772
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3773 hbits = hbits->prev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3774 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3775 hbits = g_list_find(html->html_bits, hb);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3776 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3777 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3778 hb2 = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3779
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3780 if (hb->y != hb2->y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3781 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3782 html->cursor_hb = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3783 html->cursor_pos = strlen(hb->text);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3784 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3785 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3786
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3787
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3788 if (len < len2 + strlen(hb2->text))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3789 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3790 html->cursor_hb = hb2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3791 html->cursor_pos = len - len2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3792 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3793 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3794
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3795 len2 += strlen(hb2->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3796
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3797 hb = hb2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3798
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3799 hbits = hbits->next;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3800 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3801 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3802 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3803 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3804 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3805 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3806 hb2 = (GtkHtmlBit *) hbits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3807
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3808 if (hb2->y != hb->y)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3809 break;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3810
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3811 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3812 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3813 if (!hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3814 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3815 draw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3816 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3817 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3818 hb = hb2;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3819 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3820 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3821 hb2 = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3822
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3823 if (hb->y != hb2->y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3824 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3825 html->cursor_hb = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3826 html->cursor_pos = strlen(hb->text);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3827 break;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3828 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3829
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3830
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3831 if (len < len2 + strlen(hb2->text))
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3832 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3833 html->cursor_hb = hb2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3834 html->cursor_pos = len - len2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3835 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3836 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3837
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3838 len2 += strlen(hb2->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3839
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3840 hb = hb2;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3841
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3842 hbits = hbits->next;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3843 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3844 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3845
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3846 draw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3847
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3848 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3849
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3850 static void move_cursor_hor(GtkHtml * html, int count)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3851 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3852 GList *hbits = g_list_find(html->html_bits, html->cursor_hb);
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3853 GtkHtmlBit *hb,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3854 *hb2;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3855
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3856 undraw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3857
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3858 if (!html->html_bits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3859 return;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3860
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3861 if (!html->cursor_hb)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3862 html->cursor_hb = (GtkHtmlBit *) html->html_bits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3863
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3864 html->cursor_pos += count;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3865
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3866 if (html->cursor_pos < 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3867 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3868 if (hbits->prev)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3869 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3870 gint diff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3871 hb = html->cursor_hb;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3872 hb2 = (GtkHtmlBit *) hbits->prev->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3873 diff = html->cursor_pos + strlen(hb2->text) + 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3874 if (hb->y == hb2->y)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3875 --diff;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3876
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3877 html->cursor_pos = diff;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3878
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3879 html->cursor_hb = (GtkHtmlBit *) hbits->prev->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3880 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3881 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3882 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3883 html->cursor_pos = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3884 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3885 }
79
bfdc427b936d [gaim-migrate @ 89]
Rob Flynn <gaim@robflynn.com>
parents: 69
diff changeset
3886 else if ((unsigned) html->cursor_pos > strlen(html->cursor_hb->text))
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3887 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3888 if (hbits->next)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3889 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3890 gint diff;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3891 hb = html->cursor_hb;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3892 hb2 = (GtkHtmlBit *) hbits->next->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3893
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3894 diff = html->cursor_pos - strlen(html->cursor_hb->text) - 1;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3895 if (hb->y == hb2->y)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3896 ++diff;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3897 html->cursor_pos = diff;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3898 html->cursor_hb = (GtkHtmlBit *) hbits->next->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3899 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3900 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3901 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3902 html->cursor_pos = strlen(html->cursor_hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3903 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3904
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3905 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3906
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3907 draw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3908 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3909
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3910 static void move_beginning_of_line(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3911 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3912 GList *hbits = g_list_find(html->html_bits, html->cursor_hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3913 GtkHtmlBit *hb = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3914 gint y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3915
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3916 undraw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3917
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3918 if (!html->html_bits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3919 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3920
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3921 if (!html->cursor_hb)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3922 html->cursor_hb = (GtkHtmlBit *) html->html_bits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3923
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3924 y = html->cursor_hb->y;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3925
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3926 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3927 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3928 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3929
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3930 if (y != hb->y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3931 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3932 hb = (GtkHtmlBit *) hbits->next->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3933 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3934 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3935
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3936 hbits = hbits->prev;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3937 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3938 if (!hbits)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3939 html->cursor_hb = (GtkHtmlBit *) html->html_bits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3940 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3941 html->cursor_hb = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3942
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3943 html->cursor_pos = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3944
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3945
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3946 draw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3947
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3948
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3949 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3950
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3951 static void move_end_of_line(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3952 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3953 GList *hbits = g_list_find(html->html_bits, html->cursor_hb);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3954 GtkHtmlBit *hb = NULL;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3955 gint y;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3956
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3957 undraw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3958
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3959 if (!html->html_bits)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3960 return;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3961
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3962 if (!html->cursor_hb)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3963 html->cursor_hb = (GtkHtmlBit *) html->html_bits->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3964
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3965 y = html->cursor_hb->y;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3966
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3967 while (hbits)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3968 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3969 hb = (GtkHtmlBit *) hbits->data;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3970
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3971 if (y != hb->y)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3972 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3973 hb = (GtkHtmlBit *) hbits->prev->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3974 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3975 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3976
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3977 hbits = hbits->next;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3978 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3979 if (!hbits)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3980 html->cursor_hb = (GtkHtmlBit *) g_list_last(html->html_bits)->data;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3981 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3982 html->cursor_hb = hb;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3983
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3984 html->cursor_pos = strlen(html->cursor_hb->text);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3985
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3986
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3987 draw_cursor(html);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3988
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3989
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3990 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3991
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3992
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3993
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3994 static gint gtk_html_key_press(GtkWidget * widget, GdkEventKey * event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3995 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3996 GtkHtml *html;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3997 gchar key;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3998 gint return_val;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3999
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4000 g_return_val_if_fail(widget != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4001 g_return_val_if_fail(GTK_IS_HTML(widget), FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4002 g_return_val_if_fail(event != NULL, FALSE);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4003
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4004 return_val = FALSE;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4005
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4006 html = GTK_HTML(widget);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4007
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4008 key = event->keyval;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4009 return_val = TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4010
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4011
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4012 if (html->editable == FALSE)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4013 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4014 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4015 * switch (event->keyval) {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4016 * case GDK_Home:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4017 * if (event->state & GDK_CONTROL_MASK)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4018 * scroll_int (text, -text->vadj->value);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4019 * else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4020 * return_val = FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4021 * break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4022 * case GDK_End:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4023 * if (event->state & GDK_CONTROL_MASK)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4024 * scroll_int (text, +text->vadj->upper);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4025 * else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4026 * return_val = FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4027 * break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4028 * case GDK_Page_Up: scroll_int (text, -text->vadj->page_increment); break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4029 * case GDK_Page_Down: scroll_int (text, +text->vadj->page_increment); break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4030 * case GDK_Up: scroll_int (text, -KEY_SCROLL_PIXELS); break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4031 * case GDK_Down: scroll_int (text, +KEY_SCROLL_PIXELS); break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4032 * case GDK_Return:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4033 * if (event->state & GDK_CONTROL_MASK)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4034 * gtk_signal_emit_by_name (GTK_OBJECT (text), "activate");
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4035 * else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4036 * return_val = FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4037 * break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4038 * default:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4039 * return_val = FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4040 * break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4041 * }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4042 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4043 }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4044 else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4045 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4046
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4047 switch (event->keyval)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4048 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4049 case GDK_Home:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4050 move_beginning_of_line(html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4051 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4052 case GDK_End:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4053 move_end_of_line(html);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4054 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4055 /*
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4056 * case GDK_Page_Up:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4057 * move_cursor_page_ver (html, -1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4058 * break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4059 * case GDK_Page_Down:
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4060 * move_cursor_page_ver (html, +1);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4061 * break;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4062 */
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4063 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4064 * CUA has Ctrl-Up/Ctrl-Down as paragraph up down
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4065 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4066 case GDK_Up:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4067 move_cursor_ver(html, -1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4068 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4069 case GDK_Down:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4070 move_cursor_ver(html, +1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4071 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4072 case GDK_Left:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4073 move_cursor_hor(html, -1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4074 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4075 case GDK_Right:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4076 move_cursor_hor(html, +1);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4077 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4078 #if 0
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4079 case GDK_BackSpace:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4080 if (event->state & GDK_CONTROL_MASK)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4081 gtk_text_delete_backward_word(text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4082 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4083 gtk_text_delete_backward_character(text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4084 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4085 case GDK_Clear:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4086 gtk_text_delete_line(text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4087 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4088 case GDK_Insert:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4089 if (event->state & GDK_SHIFT_MASK)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4090 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4091 extend_selection = FALSE;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4092 gtk_editable_paste_clipboard(editable);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4093 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4094 else if (event->state & GDK_CONTROL_MASK)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4095 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4096 gtk_editable_copy_clipboard(editable);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4097 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4098 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4099 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4100 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4101 * gtk_toggle_insert(text) -- IMPLEMENT
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4102 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4103 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4104 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4105 case GDK_Delete:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4106 if (event->state & GDK_CONTROL_MASK)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4107 gtk_text_delete_forward_word(text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4108 else if (event->state & GDK_SHIFT_MASK)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4109 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4110 extend_selection = FALSE;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4111 gtk_editable_cut_clipboard(editable);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4112 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4113 else
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4114 gtk_text_delete_forward_character(text);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4115 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4116 case GDK_Tab:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4117 position = text->point.index;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4118 gtk_editable_insert_text(editable, "\t", 1, &position);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4119 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4120 case GDK_Return:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4121 if (event->state & GDK_CONTROL_MASK)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4122 gtk_signal_emit_by_name(GTK_OBJECT(text), "activate");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4123 else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4124 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4125 position = text->point.index;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4126 gtk_editable_insert_text(editable, "\n", 1, &position);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4127 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4128 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4129 case GDK_Escape:
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4130 /*
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4131 * Don't insert literally
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4132 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4133 return_val = FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4134 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4135 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4136 default:
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4137 return_val = FALSE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4138
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4139 #if 0
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4140 if (event->state & GDK_CONTROL_MASK)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4141 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4142 if ((key >= 'A') && (key <= 'Z'))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4143 key -= 'A' - 'a';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4144
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4145 if ((key >= 'a') && (key <= 'z')
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4146 && control_keys[(int) (key - 'a')])
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4147 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4148 (*control_keys[(int) (key - 'a')]) (editable, event->time);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4149 return_val = TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4150 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4151
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4152 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4153 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4154 else if (event->state & GDK_MOD1_MASK)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4155 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4156 if ((key >= 'A') && (key <= 'Z'))
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4157 key -= 'A' - 'a';
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4158
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4159 if ((key >= 'a') && (key <= 'z') && alt_keys[(int) (key - 'a')])
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4160 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4161 (*alt_keys[(int) (key - 'a')]) (editable, event->time);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4162 return_val = TRUE;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4163 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4164 break;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4165 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4166 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4167 /*
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4168 * if (event->length > 0) {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4169 * html->cursor_pos++;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4170 * gtk_editable_insert_text (editable, event->string, event->length, &position);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4171 *
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4172 * return_val = TRUE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4173 * }
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4174 * else
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4175 * return_val = FALSE;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4176 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4177 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4178
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4179 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4180
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4181 return return_val;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4182 }
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4183
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4184 void gtk_html_freeze(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4185 {
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4186 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4187 g_return_if_fail(GTK_IS_HTML(html));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4188
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4189 html->frozen++;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4190 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4191
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4192 void gtk_html_thaw(GtkHtml * html)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4193 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4194 GdkRectangle area;
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4195
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4196 g_return_if_fail(html != NULL);
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4197 g_return_if_fail(GTK_IS_HTML(html));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4198
481
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
4199 gtk_html_append_text(html, NULL, 0);
64afc8f41bcb [gaim-migrate @ 491]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 353
diff changeset
4200
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4201 html->frozen--;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4202
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4203 if (html->frozen < 0)
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4204 html->frozen = 0;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4205
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4206 if (html->frozen == 0)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4207 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4208 if (html->html_area)
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4209 {
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4210 gint width,
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4211 height;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4212 area.x = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4213 area.y = 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4214
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4215 gdk_window_get_size(html->html_area, &width, &height);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4216
12
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4217 area.width = width;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4218 area.height = height;
76ab3403bf02 [gaim-migrate @ 21]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4219
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4220 expose_html(html, &area, TRUE);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4221 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4222 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4223 }