Mercurial > pidgin.yaz
annotate pidgin/gtkwebview.c @ 32602:3b4c865dc2ce
Use pidgin_create_webview in the gtknotify code.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 09 Sep 2011 02:40:51 +0000 |
parents | 8e1ec44ede75 |
children | e7eba7a6a989 |
rev | line source |
---|---|
32526 | 1 /* |
2 * @file gtkwebview.c GTK+ WebKitWebView wrapper class. | |
3 * @ingroup pidgin | |
4 */ | |
5 | |
6 /* pidgin | |
7 * | |
8 * Pidgin is the legal property of its developers, whose names are too numerous | |
9 * to list here. Please refer to the COPYRIGHT file distributed with this | |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
32526 | 14 * the Free Software Foundation; either version 2 of the License, or |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
25 * | |
26 */ | |
27 | |
28 #ifdef HAVE_CONFIG_H | |
29 #include <config.h> | |
30 #endif | |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
31 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
32 #include <ctype.h> |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
33 #include <string.h> |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
34 #include <glib.h> |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
35 #include <glib/gstdio.h> |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
36 #include <JavaScriptCore/JavaScript.h> |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
37 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
38 #include "util.h" |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
39 #include "gtkwebview.h" |
32526 | 40 #include "imgstore.h" |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
41 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
42 static WebKitWebViewClass *parent_class = NULL; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
43 |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
44 struct GtkWebViewPriv { |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
45 GHashTable *images; /**< a map from id to temporary file for the image */ |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
46 gboolean empty; /**< whether anything has been appended **/ |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
47 |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
48 /* JS execute queue */ |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
49 GQueue *js_queue; |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
50 gboolean is_loading; |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
51 GtkAdjustment *vadj; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
52 guint scroll_src; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
53 GTimer *scroll_time; |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
54 }; |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
55 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
56 GtkWidget * |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
57 gtk_webview_new(void) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
58 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
59 GtkWebView* ret = GTK_WEBVIEW(g_object_new(gtk_webview_get_type(), NULL)); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
60 return GTK_WIDGET(ret); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
61 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
62 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
63 static char * |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
64 get_image_filename_from_id(GtkWebView* view, int id) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
65 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
66 char *filename = NULL; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
67 FILE *file; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
68 PurpleStoredImage* img; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
69 |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
70 if (!view->priv->images) |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
71 view->priv->images = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
72 |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
73 filename = (char *)g_hash_table_lookup(view->priv->images, GINT_TO_POINTER(id)); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
74 if (filename) |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
75 return filename; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
76 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
77 /* else get from img store */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
78 file = purple_mkstemp(&filename, TRUE); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
79 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
80 img = purple_imgstore_find_by_id(id); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
81 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
82 fwrite(purple_imgstore_get_data(img), purple_imgstore_get_size(img), 1, file); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
83 g_hash_table_insert(view->priv->images, GINT_TO_POINTER(id), filename); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
84 fclose(file); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
85 return filename; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
86 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
87 |
32583 | 88 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
89 clear_single_image(gpointer key, gpointer value, gpointer userdata) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
90 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
91 g_unlink((char *)value); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
92 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
93 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
94 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
95 clear_images(GtkWebView *view) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
96 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
97 if (!view->priv->images) |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
98 return; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
99 g_hash_table_foreach(view->priv->images, clear_single_image, NULL); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
100 g_hash_table_unref(view->priv->images); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
101 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
102 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
103 /* |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
104 * Replace all <img id=""> tags with <img src="">. I hoped to never |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
105 * write any HTML parsing code, but I'm forced to do this, until |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
106 * purple changes the way it works. |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
107 */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
108 static char * |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
109 replace_img_id_with_src(GtkWebView *view, const char *html) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
110 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
111 GString *buffer = g_string_sized_new(strlen(html)); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
112 const char* cur = html; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
113 char *id; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
114 int nid; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
115 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
116 while (*cur) { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
117 const char *img = strstr(cur, "<img"); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
118 if (!img) { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
119 g_string_append(buffer, cur); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
120 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
121 } else |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
122 g_string_append_len(buffer, cur, img - cur); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
123 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
124 cur = strstr(img, "/>"); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
125 if (!cur) |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
126 cur = strstr(img, ">"); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
127 |
32527 | 128 if (!cur) { /* invalid html? */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
129 g_string_printf(buffer, "%s", html); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
130 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
131 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
132 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
133 if (strstr(img, "src=") || !strstr(img, "id=")) { |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
134 g_string_printf(buffer, "%s", html); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
135 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
136 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
137 |
32527 | 138 /* |
139 * if this is valid HTML, then I can be sure that it | |
140 * has an id= and does not have an src=, since | |
141 * '=' cannot appear in parameters. | |
142 */ | |
143 | |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
144 id = strstr(img, "id=") + 3; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
145 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
146 /* *id can't be \0, since a ">" appears after this */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
147 if (isdigit(*id)) |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
148 nid = atoi(id); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
149 else |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
150 nid = atoi(id + 1); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
151 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
152 /* let's dump this, tag and then dump the src information */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
153 g_string_append_len(buffer, img, cur - img); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
154 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
155 g_string_append_printf(buffer, " src='file://%s' ", get_image_filename_from_id(view, nid)); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
156 } |
32527 | 157 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
158 return g_string_free(buffer, FALSE); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
159 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
160 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
161 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
162 gtk_webview_finalize(GObject *view) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
163 { |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
164 gpointer temp; |
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
165 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
166 while ((temp = g_queue_pop_head(GTK_WEBVIEW(view)->priv->js_queue))) |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
167 g_free(temp); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
168 g_queue_free(GTK_WEBVIEW(view)->priv->js_queue); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
169 |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
170 clear_images(GTK_WEBVIEW(view)); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
171 g_free(GTK_WEBVIEW(view)->priv); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
172 G_OBJECT_CLASS(parent_class)->finalize(G_OBJECT(view)); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
173 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
174 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
175 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
176 gtk_webview_class_init(GtkWebViewClass *klass, gpointer userdata) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
177 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
178 parent_class = g_type_class_ref(webkit_web_view_get_type()); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
179 G_OBJECT_CLASS(klass)->finalize = gtk_webview_finalize; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
180 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
181 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
182 static gboolean |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
183 webview_link_clicked(WebKitWebView *view, |
32527 | 184 WebKitWebFrame *frame, |
185 WebKitNetworkRequest *request, | |
186 WebKitWebNavigationAction *navigation_action, | |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
187 WebKitWebPolicyDecision *policy_decision) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
188 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
189 const gchar *uri; |
32587
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
190 WebKitWebNavigationReason reason; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
191 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
192 uri = webkit_network_request_get_uri(request); |
32587
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
193 reason = webkit_web_navigation_action_get_reason(navigation_action); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
194 |
32587
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
195 if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
196 /* the gtk imhtml way was to create an idle cb, not sure |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
197 * why, so right now just using purple_notify_uri directly */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
198 purple_notify_uri(NULL, uri); |
32587
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
199 } |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
200 |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
201 webkit_web_policy_decision_use(policy_decision); |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32583
diff
changeset
|
202 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
203 return TRUE; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
204 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
205 |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
206 static gboolean |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
207 process_js_script_queue(GtkWebView *view) |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
208 { |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
209 char *script; |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
210 if (view->priv->is_loading) |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
211 return FALSE; /* we will be called when loaded */ |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
212 if (!view->priv->js_queue || g_queue_is_empty(view->priv->js_queue)) |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
213 return FALSE; /* nothing to do! */ |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
214 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
215 script = g_queue_pop_head(view->priv->js_queue); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
216 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(view), script); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
217 g_free(script); |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
218 |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
219 return TRUE; /* there may be more for now */ |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
220 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
221 |
32583 | 222 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
223 webview_load_started(WebKitWebView *view, |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
224 WebKitWebFrame *frame, |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
225 gpointer userdata) |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
226 { |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
227 /* is there a better way to test for is_loading? */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
228 GTK_WEBVIEW(view)->priv->is_loading = TRUE; |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
229 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
230 |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
231 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
232 webview_load_finished(WebKitWebView *view, |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
233 WebKitWebFrame *frame, |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
234 gpointer userdata) |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
235 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
236 GTK_WEBVIEW(view)->priv->is_loading = FALSE; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
237 g_idle_add((GSourceFunc)process_js_script_queue, view); |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
238 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
239 |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
240 void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
241 gtk_webview_safe_execute_script(GtkWebView *view, const char *script) |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
242 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
243 g_queue_push_tail(view->priv->js_queue, g_strdup(script)); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
244 g_idle_add((GSourceFunc)process_js_script_queue, view); |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
245 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
246 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
247 static void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
248 gtk_webview_init(GtkWebView *view, gpointer userdata) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
249 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
250 view->priv = g_new0(struct GtkWebViewPriv, 1); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
251 g_signal_connect(view, "navigation-policy-decision-requested", |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
252 G_CALLBACK(webview_link_clicked), |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
253 view); |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
254 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
255 g_signal_connect(view, "load-started", |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
256 G_CALLBACK(webview_load_started), |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
257 view); |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
258 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
259 g_signal_connect(view, "load-finished", |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
260 G_CALLBACK(webview_load_finished), |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
261 view); |
32583 | 262 |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
263 view->priv->empty = TRUE; |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
264 view->priv->js_queue = g_queue_new(); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
265 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
266 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
267 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
268 void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
269 gtk_webview_load_html_string_with_imgstore(GtkWebView *view, const char *html) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
270 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
271 char *html_imged; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
272 |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
273 clear_images(view); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
274 html_imged = replace_img_id_with_src(view, html); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
275 webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(view), html_imged, "file:///"); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
276 g_free(html_imged); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
277 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
278 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
279 char * |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
280 gtk_webview_quote_js_string(const char *text) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
281 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
282 GString *str = g_string_new("\""); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
283 const char *cur = text; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
284 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
285 while (cur && *cur) { |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
286 switch (*cur) { |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
287 case '\\': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
288 g_string_append(str, "\\\\"); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
289 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
290 case '\"': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
291 g_string_append(str, "\\\""); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
292 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
293 case '\r': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
294 g_string_append(str, "<br/>"); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
295 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
296 case '\n': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
297 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
298 default: |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
299 g_string_append_c(str, *cur); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
300 } |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
301 cur++; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
302 } |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
303 g_string_append_c(str, '"'); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
304 return g_string_free(str, FALSE); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
305 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
306 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
307 void |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
308 gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj) |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
309 { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
310 webview->priv->vadj = vadj; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
311 } |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
312 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
313 /* this is a "hack", my plan is to eventually handle this |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
314 * correctly using a signals and a plugin: the plugin will have |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
315 * the information as to what javascript function to call. It seems |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
316 * wrong to hardcode that here. |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
317 */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
318 void |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
319 gtk_webview_append_html(GtkWebView *view, const char *html) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
320 { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
321 char *escaped = gtk_webview_quote_js_string(html); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
322 char *script = g_strdup_printf("document.write(%s)", escaped); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
323 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(view), script); |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
324 view->priv->empty = FALSE; |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
325 gtk_webview_scroll_to_end(view, TRUE); |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
326 g_free(script); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
327 g_free(escaped); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
328 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
329 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
330 gboolean |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
331 gtk_webview_is_empty(GtkWebView *view) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
332 { |
32541
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32527
diff
changeset
|
333 return view->priv->empty; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
334 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
335 |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
336 #define MAX_SCROLL_TIME 0.4 /* seconds */ |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
337 #define SCROLL_DELAY 33 /* milliseconds */ |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
338 |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
339 /* |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
340 * Smoothly scroll a WebView. |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
341 * |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
342 * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
343 */ |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
344 static gboolean |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
345 smooth_scroll_cb(gpointer data) |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
346 { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
347 struct GtkWebViewPriv *priv = data; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
348 GtkAdjustment *adj = priv->vadj; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
349 gdouble max_val = adj->upper - adj->page_size; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
350 gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
351 |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
352 g_return_val_if_fail(priv->scroll_time != NULL, FALSE); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
353 |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
354 if (g_timer_elapsed(priv->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
355 /* time's up. jump to the end and kill the timer */ |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
356 gtk_adjustment_set_value(adj, max_val); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
357 g_timer_destroy(priv->scroll_time); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
358 priv->scroll_time = NULL; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
359 g_source_remove(priv->scroll_src); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
360 priv->scroll_src = 0; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
361 return FALSE; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
362 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
363 |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
364 /* scroll by 1/3rd the remaining distance */ |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
365 gtk_adjustment_set_value(adj, scroll_val); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
366 return TRUE; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
367 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
368 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
369 static gboolean |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
370 scroll_idle_cb(gpointer data) |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
371 { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
372 struct GtkWebViewPriv *priv = data; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
373 GtkAdjustment *adj = priv->vadj; |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
374 if (adj) { |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
375 gtk_adjustment_set_value(adj, adj->upper - adj->page_size); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
376 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
377 priv->scroll_src = 0; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
378 return FALSE; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
379 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
380 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
381 void |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
382 gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth) |
32581
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
383 { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
384 struct GtkWebViewPriv *priv = webview->priv; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
385 if (priv->scroll_time) |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
386 g_timer_destroy(priv->scroll_time); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
387 if (priv->scroll_src) |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
388 g_source_remove(priv->scroll_src); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
389 if(smooth) { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
390 priv->scroll_time = g_timer_new(); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
391 priv->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, priv, NULL); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
392 } else { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
393 priv->scroll_time = NULL; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
394 priv->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, priv, NULL); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
395 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
396 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32570
diff
changeset
|
397 |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
398 GType |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
399 gtk_webview_get_type(void) |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
400 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
401 static GType mview_type = 0; |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
402 if (G_UNLIKELY(mview_type == 0)) { |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
403 static const GTypeInfo mview_info = { |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
404 sizeof(GtkWebViewClass), |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
405 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
406 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
407 (GClassInitFunc) gtk_webview_class_init, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
408 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
409 NULL, |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
410 sizeof(GtkWebView), |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
411 0, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
412 (GInstanceInitFunc) gtk_webview_init, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
413 NULL |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
414 }; |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
415 mview_type = g_type_register_static(webkit_web_view_get_type(), |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
416 "GtkWebView", &mview_info, 0); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
417 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
418 return mview_type; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
419 } |
32594
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32587
diff
changeset
|
420 |