annotate pidgin/gtkwebview.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents 68fe7b5211a7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32526
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
1 /*
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
2 * @file gtkwebview.c GTK+ WebKitWebView wrapper class.
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
3 * @ingroup pidgin
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
4 */
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
5
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
6 /* pidgin
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
7 *
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
10 * source distribution.
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
11 *
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
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
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
15 * (at your option) any later version.
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
16 *
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
17 * This program is distributed in the hope that it will be useful,
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
20 * GNU General Public License for more details.
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
21 *
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
22 * You should have received a copy of the GNU General Public License
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
23 * along with this program; if not, write to the Free Software
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
25 *
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
26 */
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
27
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
28 #ifdef HAVE_CONFIG_H
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
29 #include <config.h>
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
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
a2fd5f08ed49 cleaning up code.
tdrhq@soc.pidgin.im
parents: 32522
diff changeset
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 */
32660
68fe7b5211a7 Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <mark@kingant.net>
parents: 32604
diff changeset
46 gboolean empty; /**< whether anything has been appended **/
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
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
1795afae76f2 Fix more white spaces issues.
masca@cpw.pidgin.im
parents: 32581
diff changeset
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
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
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
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
138 /*
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
139 * if this is valid HTML, then I can be sure that it
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
140 * has an id= and does not have an src=, since
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
141 * '=' cannot appear in parameters.
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
142 */
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
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
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
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
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
184 WebKitWebFrame *frame,
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
185 WebKitNetworkRequest *request,
2af29d62cfde more cleanup.
tdrhq@soc.pidgin.im
parents: 32526
diff changeset
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);
32604
e7eba7a6a989 Let webview manage the navigation ONLY if the reason is the user clicked a link.
masca@cpw.pidgin.im
parents: 32594
diff changeset
199 } else
e7eba7a6a989 Let webview manage the navigation ONLY if the reason is the user clicked a link.
masca@cpw.pidgin.im
parents: 32594
diff changeset
200 webkit_web_policy_decision_use(policy_decision);
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
201
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
202 return TRUE;
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
203 }
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
204
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
205 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
206 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
207 {
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 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
209 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
210 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
211 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
212 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
213
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
214 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
215 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
216 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
217
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 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
219 }
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
32583
1795afae76f2 Fix more white spaces issues.
masca@cpw.pidgin.im
parents: 32581
diff changeset
221 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
222 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
223 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
224 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
225 {
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 /* 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
227 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
228 }
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 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
231 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
232 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
233 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
234 {
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
235 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
236 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
237 }
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 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
240 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
241 {
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
242 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
243 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
244 }
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
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
246 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
247 gtk_webview_init(GtkWebView *view, gpointer userdata)
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
248 {
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
249 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
250 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
251 G_CALLBACK(webview_link_clicked),
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
252 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
253
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
254 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
255 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
256 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
257
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
258 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
259 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
260 view);
32583
1795afae76f2 Fix more white spaces issues.
masca@cpw.pidgin.im
parents: 32581
diff changeset
261
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
262 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
263 view->priv->js_queue = g_queue_new();
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
264 }
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 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
268 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
269 {
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
270 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
271
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
272 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
273 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
274 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
275 g_free(html_imged);
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
276 }
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
277
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
278 char *
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
279 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
280 {
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
281 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
282 const char *cur = text;
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
283
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
284 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
285 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
286 case '\\':
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
287 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
288 break;
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
289 case '\"':
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
290 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
291 break;
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
292 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
293 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
294 break;
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
295 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
296 break;
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
297 default:
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
298 g_string_append_c(str, *cur);
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
299 }
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
300 cur++;
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
301 }
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
302 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
303 return g_string_free(str, FALSE);
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
304 }
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
305
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
306 void
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
307 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
308 {
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
309 webview->priv->vadj = vadj;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
310 }
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
311
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
312 /* 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
313 * 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
314 * 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
315 * wrong to hardcode that here.
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
316 */
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
317 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
318 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
319 {
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
320 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
321 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
322 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
323 view->priv->empty = FALSE;
32581
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
324 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
325 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
326 g_free(escaped);
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
327 }
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
328
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
329 gboolean
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
330 gtk_webview_is_empty(GtkWebView *view)
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
331 {
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
332 return view->priv->empty;
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
333 }
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
334
32581
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
335 #define MAX_SCROLL_TIME 0.4 /* seconds */
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
336 #define SCROLL_DELAY 33 /* milliseconds */
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
337
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 * Smoothly scroll a WebView.
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
340 *
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
341 * @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
342 */
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
343 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
344 smooth_scroll_cb(gpointer data)
32581
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
345 {
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
346 struct GtkWebViewPriv *priv = data;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
347 GtkAdjustment *adj = priv->vadj;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
348 gdouble max_val = adj->upper - adj->page_size;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
349 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
350
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
351 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
352
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
353 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
354 /* 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
355 gtk_adjustment_set_value(adj, max_val);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
356 g_timer_destroy(priv->scroll_time);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
357 priv->scroll_time = NULL;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
358 g_source_remove(priv->scroll_src);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
359 priv->scroll_src = 0;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
360 return FALSE;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
361 }
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 /* scroll by 1/3rd the remaining distance */
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
364 gtk_adjustment_set_value(adj, scroll_val);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
365 return TRUE;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
366 }
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
367
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
368 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
369 scroll_idle_cb(gpointer data)
32581
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
370 {
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
371 struct GtkWebViewPriv *priv = data;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
372 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
373 if (adj) {
32581
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
374 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
375 }
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
376 priv->scroll_src = 0;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
377 return FALSE;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
378 }
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
379
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
380 void
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
381 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
382 {
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
383 struct GtkWebViewPriv *priv = webview->priv;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
384 if (priv->scroll_time)
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
385 g_timer_destroy(priv->scroll_time);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
386 if (priv->scroll_src)
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
387 g_source_remove(priv->scroll_src);
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
388 if(smooth) {
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
389 priv->scroll_time = g_timer_new();
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
390 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
391 } else {
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
392 priv->scroll_time = NULL;
24c8a98a6acc webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents: 32570
diff changeset
393 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
394 }
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
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
397 GType
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
398 gtk_webview_get_type(void)
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
399 {
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
400 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
401 if (G_UNLIKELY(mview_type == 0)) {
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
402 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
403 sizeof(GtkWebViewClass),
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
404 NULL,
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 (GClassInitFunc) gtk_webview_class_init,
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
407 NULL,
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
408 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
409 sizeof(GtkWebView),
32522
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
410 0,
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
411 (GInstanceInitFunc) gtk_webview_init,
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
412 NULL
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
413 };
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
414 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
415 "GtkWebView", &mview_info, 0);
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
416 }
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
417 return mview_type;
ac42a0dfda48 Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff changeset
418 }
32594
8e1ec44ede75 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32587
diff changeset
419