Mercurial > pidgin.yaz
annotate pidgin/gtkwebview.c @ 32543:25d99f3621bb
removed some ugly pointless pieces of code.
author | tdrhq@soc.pidgin.im |
---|---|
date | Mon, 10 Aug 2009 07:47:37 +0000 |
parents | 3bd8fb942ea4 |
children | 1cebf9aa291a |
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 | |
13 * under the terms of the GNU General Public License as published by | |
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; |
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
|
51 }; |
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
|
52 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
53 GtkWidget* gtk_webview_new () |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
54 { |
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
|
55 GtkWebView* ret = GTK_WEBVIEW (g_object_new(gtk_webview_get_type(), NULL)); |
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
|
56 return GTK_WIDGET (ret); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
57 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
58 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
59 static char* |
32526 | 60 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
|
61 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
62 char *filename = NULL; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
63 FILE *file; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
64 PurpleStoredImage* img; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
65 |
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
|
66 if (!view->priv->images) |
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
|
67 view->priv->images = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
68 |
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
|
69 filename = (char*) g_hash_table_lookup (view->priv->images, GINT_TO_POINTER (id)); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
70 if (filename) return filename; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
71 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
72 /* else get from img store */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
73 file = purple_mkstemp (&filename, TRUE); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
74 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
75 img = purple_imgstore_find_by_id (id); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
76 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
77 fwrite (purple_imgstore_get_data (img), purple_imgstore_get_size (img), 1, file); |
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
|
78 g_hash_table_insert (view->priv->images, GINT_TO_POINTER (id), filename); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
79 fclose (file); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
80 return filename; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
81 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
82 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
83 static void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
84 clear_single_image (gpointer key, gpointer value, gpointer userdata) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
85 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
86 g_unlink ((char*) value); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
87 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
88 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
89 static void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
90 clear_images (GtkWebView* view) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
91 { |
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
|
92 if (!view->priv->images) return; |
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
|
93 g_hash_table_foreach (view->priv->images, clear_single_image, NULL); |
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
|
94 g_hash_table_unref (view->priv->images); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
95 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
96 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
97 /* |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
98 * Replace all <img id=""> tags with <img src="">. I hoped to never |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
99 * write any HTML parsing code, but I'm forced to do this, until |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
100 * purple changes the way it works. |
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 static char* |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
103 replace_img_id_with_src (GtkWebView *view, const char* html) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
104 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
105 GString *buffer = g_string_sized_new (strlen (html)); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
106 const char* cur = html; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
107 char *id; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
108 int nid; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
109 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
110 while (*cur) { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
111 const char* img = strstr (cur, "<img"); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
112 if (!img) { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
113 g_string_append (buffer, cur); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
114 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
115 } else |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
116 g_string_append_len (buffer, cur, img - cur); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
117 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
118 cur = strstr (img, "/>"); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
119 if (!cur) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
120 cur = strstr (img, ">"); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
121 |
32527 | 122 if (!cur) { /* invalid html? */ |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
123 g_string_printf (buffer, "%s", html); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
124 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
125 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
126 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
127 if (strstr (img, "src=") || !strstr (img, "id=")) { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
128 g_string_printf (buffer, "%s", html); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
129 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
130 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
131 |
32527 | 132 /* |
133 * if this is valid HTML, then I can be sure that it | |
134 * has an id= and does not have an src=, since | |
135 * '=' cannot appear in parameters. | |
136 */ | |
137 | |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
138 id = strstr (img, "id=") + 3; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
139 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
140 /* *id can't be \0, since a ">" appears after this */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
141 if (isdigit (*id)) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
142 nid = atoi (id); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
143 else |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
144 nid = atoi (id+1); |
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 /* let's dump this, tag and then dump the src information */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
147 g_string_append_len (buffer, img, cur - img); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
148 |
32526 | 149 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
|
150 } |
32527 | 151 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
152 return g_string_free (buffer, FALSE); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
153 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
154 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
155 static void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
156 gtk_webview_finalize (GObject *view) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
157 { |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
158 gpointer temp; |
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
159 |
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
160 while ((temp = g_queue_pop_head (GTK_WEBVIEW(view)->priv->js_queue))) |
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
161 g_free (temp); |
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
162 g_queue_free (GTK_WEBVIEW(view)->priv->js_queue); |
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
163 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
164 clear_images (GTK_WEBVIEW (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
|
165 g_free (GTK_WEBVIEW(view)->priv); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
166 G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT(view)); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
167 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
168 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
169 static void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
170 gtk_webview_class_init (GtkWebViewClass *klass, gpointer userdata) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
171 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
172 parent_class = g_type_class_ref (webkit_web_view_get_type ()); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
173 G_OBJECT_CLASS (klass)->finalize = gtk_webview_finalize; |
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 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
176 static gboolean |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
177 webview_link_clicked (WebKitWebView *view, |
32527 | 178 WebKitWebFrame *frame, |
179 WebKitNetworkRequest *request, | |
180 WebKitWebNavigationAction *navigation_action, | |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
181 WebKitWebPolicyDecision *policy_decision) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
182 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
183 const gchar *uri; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
184 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
185 uri = webkit_network_request_get_uri (request); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
186 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
187 /* the gtk imhtml way was to create an idle cb, not sure |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
188 * why, so right now just using purple_notify_uri directly */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
189 purple_notify_uri (NULL, uri); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
190 return TRUE; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
191 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
192 |
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
|
193 static gboolean |
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
|
194 process_js_script_queue (GtkWebView *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
|
195 { |
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
|
196 char *script; |
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
|
197 if (view->priv->is_loading) return FALSE; /* we will be called when loaded */ |
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
|
198 if (!view->priv->js_queue || g_queue_is_empty (view->priv->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
|
199 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
|
200 |
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
|
201 script = g_queue_pop_head (view->priv->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
|
202 webkit_web_view_execute_script (WEBKIT_WEB_VIEW(view), script); |
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
|
203 g_free (script); |
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
|
204 |
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 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
|
206 } |
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 static void |
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 webview_load_started (WebKitWebView *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
|
210 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
|
211 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
|
212 { |
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 /* is there a better way to test for is_loading? */ |
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 GTK_WEBVIEW(view)->priv->is_loading = true; |
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
|
215 } |
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
|
216 |
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 static void |
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 webview_load_finished (WebKitWebView *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
|
219 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
|
220 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
|
221 { |
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
|
222 GTK_WEBVIEW(view)->priv->is_loading = false; |
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 g_idle_add ((GSourceFunc) process_js_script_queue, 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
|
224 } |
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 void |
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 gtk_webview_safe_execute_script (GtkWebView *view, const char* script) |
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 g_queue_push_tail (view->priv->js_queue, g_strdup (script)); |
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 g_idle_add ((GSourceFunc)process_js_script_queue, 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
|
231 } |
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 |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
233 static void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
234 gtk_webview_init (GtkWebView *view, gpointer userdata) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
235 { |
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
|
236 view->priv = g_new0 (struct GtkWebViewPriv, 1); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
237 g_signal_connect (view, "navigation-policy-decision-requested", |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
238 G_CALLBACK (webview_link_clicked), |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
239 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
|
240 |
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 g_signal_connect (view, "load-started", |
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 G_CALLBACK (webview_load_started), |
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
|
243 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
|
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 g_signal_connect (view, "load-finished", |
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 G_CALLBACK (webview_load_finished), |
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
|
247 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
|
248 |
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
|
249 view->priv->empty = TRUE; |
32542
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32541
diff
changeset
|
250 view->priv->js_queue = g_queue_new (); |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
251 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
252 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
253 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
254 void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
255 gtk_webview_load_html_string_with_imgstore (GtkWebView* view, const char* html) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
256 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
257 char* html_imged; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
258 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
259 clear_images (view); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
260 html_imged = replace_img_id_with_src (view, html); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
261 printf ("%s\n", html_imged); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
262 webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (view), html_imged, "file:///"); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
263 g_free (html_imged); |
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 char *gtk_webview_quote_js_string(const char *text) |
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 GString *str = g_string_new("\""); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
269 const char *cur = text; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
270 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
271 while (cur && *cur) { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
272 switch (*cur) { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
273 case '\\': |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
274 g_string_append(str, "\\\\"); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
275 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
276 case '\"': |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
277 g_string_append(str, "\\\""); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
278 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
279 case '\r': |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
280 g_string_append(str, "<br/>"); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
281 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
282 case '\n': |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
283 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
284 default: |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
285 g_string_append_c(str, *cur); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
286 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
287 cur ++; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
288 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
289 g_string_append_c (str, '"'); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
290 return g_string_free (str, FALSE); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
291 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
292 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
293 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
294 /* this is a "hack", my plan is to eventually handle this |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
295 * 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
|
296 * 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
|
297 * wrong to hardcode that here. |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
298 */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
299 void |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
300 gtk_webview_append_html (GtkWebView* view, const char* html) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
301 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
302 char* escaped = gtk_webview_quote_js_string (html); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
303 char* script = g_strdup_printf ("document.write(%s)", escaped); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
304 printf ("script: %s\n", script); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
305 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
|
306 view->priv->empty = FALSE; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
307 g_free (script); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
308 g_free (escaped); |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
309 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
310 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
311 gboolean gtk_webview_is_empty (GtkWebView *view) |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
312 { |
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
|
313 return view->priv->empty; |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
314 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
315 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
316 GType gtk_webview_get_type () |
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 static GType mview_type = 0; |
32527 | 319 if (G_UNLIKELY (mview_type == 0)) { |
32522
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
320 static const GTypeInfo mview_info = { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
321 sizeof (GtkWebViewClass), |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
322 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
323 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
324 (GClassInitFunc) gtk_webview_class_init, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
325 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
326 NULL, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
327 sizeof (GtkWebView), |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
328 0, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
329 (GInstanceInitFunc) gtk_webview_init, |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
330 NULL |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
331 }; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
332 mview_type = g_type_register_static(webkit_web_view_get_type (), |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
333 "GtkWebView", &mview_info, 0); |
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 return mview_type; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
336 } |