Wed, 04 Jan 2012 02:30:11 +0000
Rearrange these files a bit to group common functions
together. Use a variable to store the pointer to the private
GObject data which avoids extra casting. Also, use the GObject
way of allocating a private data structure.
| 32445 | 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 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
13 | * it under the terms of the GNU General Public License as published by |
| 32445 | 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 | ||
|
32791
a2dc8d3ee1b8
Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32774
diff
changeset
|
28 | #include "internal.h" |
|
a2dc8d3ee1b8
Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32774
diff
changeset
|
29 | #include "pidgin.h" |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
30 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
31 | #include "gtkwebview.h" |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
32 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
33 | #define MAX_SCROLL_TIME 0.4 /* seconds */ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
34 | #define SCROLL_DELAY 33 /* milliseconds */ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
35 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
36 | #define GTK_WEBVIEW_GET_PRIVATE(obj) \ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
37 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_WEBVIEW, GtkWebViewPriv)) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
38 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
39 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
40 | * Structs |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
41 | *****************************************************************************/ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
42 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
43 | typedef struct _GtkWebViewPriv { |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
44 | GHashTable *images; /**< a map from id to temporary file for the image */ |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
45 | gboolean empty; /**< whether anything has been appended **/ |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
46 | |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
47 | /* JS execute queue */ |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
48 | GQueue *js_queue; |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
49 | gboolean is_loading; |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
50 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
51 | /* Scroll adjustments */ |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
52 | GtkAdjustment *vadj; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
53 | guint scroll_src; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
54 | GTimer *scroll_time; |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
55 | } GtkWebViewPriv; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
56 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
57 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
58 | * Globals |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
59 | *****************************************************************************/ |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
60 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
61 | static WebKitWebViewClass *parent_class = NULL; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
62 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
63 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
64 | * Helpers |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
65 | *****************************************************************************/ |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
66 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
67 | static const char * |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
68 | get_image_src_from_id(GtkWebViewPriv *priv, int id) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
69 | { |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
70 | char *src; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
71 | PurpleStoredImage *img; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
72 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
73 | if (priv->images) { |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
74 | /* Check for already loaded image */ |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
75 | src = (char *)g_hash_table_lookup(priv->images, GINT_TO_POINTER(id)); |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
76 | if (src) |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
77 | return src; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
78 | } else { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
79 | priv->images = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
80 | NULL, g_free); |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
81 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
82 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
83 | /* Find image in store */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
84 | img = purple_imgstore_find_by_id(id); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
85 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
86 | src = (char *)purple_imgstore_get_filename(img); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
87 | if (src) { |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
88 | src = g_strdup_printf("file://%s", src); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
89 | } else { |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
90 | char *tmp; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
91 | tmp = purple_base64_encode(purple_imgstore_get_data(img), |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
92 | purple_imgstore_get_size(img)); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
93 | src = g_strdup_printf("data:base64,%s", tmp); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
94 | g_free(tmp); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
95 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
96 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
97 | g_hash_table_insert(priv->images, GINT_TO_POINTER(id), src); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
98 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
99 | return src; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
100 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
101 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
102 | /* |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
103 | * Replace all <img id=""> tags with <img src="">. I hoped to never |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
104 | * write any HTML parsing code, but I'm forced to do this, until |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
105 | * purple changes the way it works. |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
106 | */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
107 | static char * |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
108 | replace_img_id_with_src(GtkWebViewPriv *priv, const char *html) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
109 | { |
|
32794
cf2f759f7010
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32793
diff
changeset
|
110 | GString *buffer = g_string_new(NULL); |
|
cf2f759f7010
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32793
diff
changeset
|
111 | const char *cur = html; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
112 | char *id; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
113 | int nid; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
114 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
115 | while (*cur) { |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
116 | const char *img = strstr(cur, "<img"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
117 | if (!img) { |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
118 | g_string_append(buffer, cur); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
119 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
120 | } else |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
121 | g_string_append_len(buffer, cur, img - cur); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
122 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
123 | cur = strstr(img, "/>"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
124 | if (!cur) |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
125 | cur = strstr(img, ">"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
126 | |
| 32446 | 127 | if (!cur) { /* invalid html? */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
128 | g_string_printf(buffer, "%s", html); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
129 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
130 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
131 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
132 | if (strstr(img, "src=") || !strstr(img, "id=")) { |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
133 | g_string_printf(buffer, "%s", html); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
134 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
135 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
136 | |
| 32446 | 137 | /* |
| 138 | * if this is valid HTML, then I can be sure that it | |
| 139 | * has an id= and does not have an src=, since | |
| 140 | * '=' cannot appear in parameters. | |
| 141 | */ | |
| 142 | ||
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
143 | id = strstr(img, "id=") + 3; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
144 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
145 | /* *id can't be \0, since a ">" appears after this */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
146 | if (isdigit(*id)) |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
147 | nid = atoi(id); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
148 | else |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
149 | nid = atoi(id + 1); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
150 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
151 | /* let's dump this, tag and then dump the src information */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
152 | g_string_append_len(buffer, img, cur - img); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
153 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
154 | g_string_append_printf(buffer, " src='%s' ", get_image_src_from_id(priv, nid)); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
155 | } |
| 32446 | 156 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
157 | return g_string_free(buffer, FALSE); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
158 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
159 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
160 | static gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
161 | process_js_script_queue(GtkWebView *webview) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
162 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
163 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
164 | char *script; |
|
32461
72fe247cc953
Yep, tested, and changed some code from previous commit. This is a hard
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32460
diff
changeset
|
165 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
166 | if (priv->is_loading) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
167 | return FALSE; /* we will be called when loaded */ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
168 | if (!priv->js_queue || g_queue_is_empty(priv->js_queue)) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
169 | return FALSE; /* nothing to do! */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
170 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
171 | script = g_queue_pop_head(priv->js_queue); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
172 | webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
173 | g_free(script); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
174 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
175 | return TRUE; /* there may be more for now */ |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
176 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
177 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
178 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
179 | webview_load_started(WebKitWebView *webview, WebKitWebFrame *frame, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
180 | gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
181 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
182 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
183 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
184 | /* is there a better way to test for is_loading? */ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
185 | priv->is_loading = TRUE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
186 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
187 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
188 | static void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
189 | webview_load_finished(WebKitWebView *webview, WebKitWebFrame *frame, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
190 | gpointer userdata) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
191 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
192 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
193 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
194 | priv->is_loading = FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
195 | g_idle_add((GSourceFunc)process_js_script_queue, webview); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
196 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
197 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
198 | static gboolean |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
199 | webview_link_clicked(WebKitWebView *webview, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
200 | WebKitWebFrame *frame, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
201 | WebKitNetworkRequest *request, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
202 | WebKitWebNavigationAction *navigation_action, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
203 | WebKitWebPolicyDecision *policy_decision, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
204 | gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
205 | { |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
206 | const gchar *uri; |
|
32506
74d884939a2c
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32502
diff
changeset
|
207 | WebKitWebNavigationReason reason; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
208 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
209 | uri = webkit_network_request_get_uri(request); |
|
32506
74d884939a2c
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32502
diff
changeset
|
210 | reason = webkit_web_navigation_action_get_reason(navigation_action); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
211 | |
|
32506
74d884939a2c
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32502
diff
changeset
|
212 | if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { |
|
74d884939a2c
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32502
diff
changeset
|
213 | /* the gtk imhtml way was to create an idle cb, not sure |
|
74d884939a2c
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32502
diff
changeset
|
214 | * why, so right now just using purple_notify_uri directly */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
215 | purple_notify_uri(NULL, uri); |
|
32523
2d37b68228b6
Let webview manage the navigation ONLY if the reason is the user clicked a link.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32513
diff
changeset
|
216 | } else |
|
2d37b68228b6
Let webview manage the navigation ONLY if the reason is the user clicked a link.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32513
diff
changeset
|
217 | webkit_web_policy_decision_use(policy_decision); |
|
32506
74d884939a2c
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32502
diff
changeset
|
218 | |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
219 | return TRUE; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
220 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
221 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
222 | /* |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
223 | * Smoothly scroll a WebView. |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
224 | * |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
225 | * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
226 | */ |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
227 | static gboolean |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
228 | smooth_scroll_cb(gpointer data) |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
229 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
230 | GtkWebViewPriv *priv = data; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
231 | GtkAdjustment *adj; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
232 | gdouble max_val; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
233 | gdouble scroll_val; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
234 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
235 | g_return_val_if_fail(priv->scroll_time != NULL, FALSE); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
236 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
237 | adj = priv->vadj; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
238 | max_val = adj->upper - adj->page_size; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
239 | scroll_val = gtk_adjustment_get_value(adj) + |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
240 | ((max_val - gtk_adjustment_get_value(adj)) / 3); |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
241 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
242 | if (g_timer_elapsed(priv->scroll_time, NULL) > MAX_SCROLL_TIME |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
243 | || scroll_val >= max_val) { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
244 | /* time's up. jump to the end and kill the timer */ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
245 | gtk_adjustment_set_value(adj, max_val); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
246 | g_timer_destroy(priv->scroll_time); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
247 | priv->scroll_time = NULL; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
248 | g_source_remove(priv->scroll_src); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
249 | priv->scroll_src = 0; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
250 | return FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
251 | } |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
252 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
253 | /* scroll by 1/3rd the remaining distance */ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
254 | gtk_adjustment_set_value(adj, scroll_val); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
255 | return TRUE; |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
256 | } |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
257 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
258 | static gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
259 | scroll_idle_cb(gpointer data) |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
260 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
261 | GtkWebViewPriv *priv = data; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
262 | GtkAdjustment *adj = priv->vadj; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
263 | if (adj) { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
264 | gtk_adjustment_set_value(adj, adj->upper - adj->page_size); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
265 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
266 | priv->scroll_src = 0; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
267 | return FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
268 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
269 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
270 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
271 | * GObject Stuff |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
272 | *****************************************************************************/ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
273 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
274 | GtkWidget * |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
275 | gtk_webview_new(void) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
276 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
277 | return GTK_WIDGET(g_object_new(gtk_webview_get_type(), NULL)); |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
278 | } |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
279 | |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
280 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
281 | gtk_webview_finalize(GObject *webview) |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
282 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
283 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
284 | gpointer temp; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
285 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
286 | while ((temp = g_queue_pop_head(priv->js_queue))) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
287 | g_free(temp); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
288 | g_queue_free(priv->js_queue); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
289 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
290 | if (priv->images) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
291 | g_hash_table_unref(priv->images); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
292 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
293 | G_OBJECT_CLASS(parent_class)->finalize(G_OBJECT(webview)); |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
294 | } |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
295 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
296 | static void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
297 | gtk_webview_class_init(GtkWebViewClass *klass, gpointer userdata) |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
298 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
299 | parent_class = g_type_class_ref(webkit_web_view_get_type()); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
300 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
301 | g_type_class_add_private(klass, sizeof(GtkWebViewPriv)); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
302 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
303 | G_OBJECT_CLASS(klass)->finalize = gtk_webview_finalize; |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
304 | } |
|
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
305 | |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
306 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
307 | gtk_webview_init(GtkWebView *webview, gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
308 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
309 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
310 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
311 | priv->empty = TRUE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
312 | priv->js_queue = g_queue_new(); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
313 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
314 | g_signal_connect(webview, "navigation-policy-decision-requested", |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
315 | G_CALLBACK(webview_link_clicked), |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
316 | webview); |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
317 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
318 | g_signal_connect(webview, "load-started", |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
319 | G_CALLBACK(webview_load_started), |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
320 | webview); |
|
32460
5771be5530d8
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
32446
diff
changeset
|
321 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
322 | g_signal_connect(webview, "load-finished", |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
323 | G_CALLBACK(webview_load_finished), |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
324 | webview); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
325 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
326 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
327 | GType |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
328 | gtk_webview_get_type(void) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
329 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
330 | static GType mview_type = 0; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
331 | if (G_UNLIKELY(mview_type == 0)) { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
332 | static const GTypeInfo mview_info = { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
333 | sizeof(GtkWebViewClass), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
334 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
335 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
336 | (GClassInitFunc)gtk_webview_class_init, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
337 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
338 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
339 | sizeof(GtkWebView), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
340 | 0, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
341 | (GInstanceInitFunc)gtk_webview_init, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
342 | NULL |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
343 | }; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
344 | mview_type = g_type_register_static(webkit_web_view_get_type(), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
345 | "GtkWebView", &mview_info, 0); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
346 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
347 | return mview_type; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
348 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
349 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
350 | /***************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
351 | * Public API functions |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
352 | *****************************************************************************/ |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
353 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
354 | gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
355 | gtk_webview_is_empty(GtkWebView *webview) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
356 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
357 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
358 | return priv->empty; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
359 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
360 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
361 | char * |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
362 | gtk_webview_quote_js_string(const char *text) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
363 | { |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
364 | GString *str = g_string_new("\""); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
365 | const char *cur = text; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
366 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
367 | while (cur && *cur) { |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
368 | switch (*cur) { |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
369 | case '\\': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
370 | g_string_append(str, "\\\\"); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
371 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
372 | case '\"': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
373 | g_string_append(str, "\\\""); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
374 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
375 | case '\r': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
376 | g_string_append(str, "<br/>"); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
377 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
378 | case '\n': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
379 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
380 | default: |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
381 | g_string_append_c(str, *cur); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
382 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
383 | cur++; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
384 | } |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
385 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
386 | g_string_append_c(str, '"'); |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
387 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
388 | return g_string_free(str, FALSE); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
389 | } |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
390 | void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
391 | gtk_webview_safe_execute_script(GtkWebView *webview, const char *script) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
392 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
393 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
394 | g_queue_push_tail(priv->js_queue, g_strdup(script)); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
395 | g_idle_add((GSourceFunc)process_js_script_queue, webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
396 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
397 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
398 | void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
399 | gtk_webview_load_html_string_with_imgstore(GtkWebView *webview, const char *html) |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
400 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
401 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
402 | char *html_imged; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
403 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
404 | if (priv->images) { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
405 | g_hash_table_unref(priv->images); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
406 | priv->images = NULL; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
407 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
408 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
409 | html_imged = replace_img_id_with_src(priv, html); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
410 | webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), html_imged, NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
411 | NULL, "file:///"); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
412 | g_free(html_imged); |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
413 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
414 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
415 | /* this is a "hack", my plan is to eventually handle this |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
416 | * correctly using a signals and a plugin: the plugin will have |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
417 | * the information as to what javascript function to call. It seems |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
418 | * wrong to hardcode that here. |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
419 | */ |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
420 | void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
421 | gtk_webview_append_html(GtkWebView *webview, const char *html) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
422 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
423 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
424 | char *escaped = gtk_webview_quote_js_string(html); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
425 | char *script = g_strdup_printf("document.write(%s)", escaped); |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
426 | webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
427 | priv->empty = FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
428 | gtk_webview_scroll_to_end(webview, TRUE); |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
429 | g_free(script); |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
430 | g_free(escaped); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
431 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
432 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
433 | void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
434 | gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj) |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
435 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
436 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
437 | priv->vadj = vadj; |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
438 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
439 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
440 | void |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
441 | gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth) |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
442 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
443 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
444 | if (priv->scroll_time) |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
445 | g_timer_destroy(priv->scroll_time); |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
446 | if (priv->scroll_src) |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
447 | g_source_remove(priv->scroll_src); |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
448 | if (smooth) { |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
449 | priv->scroll_time = g_timer_new(); |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
450 | priv->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, priv, NULL); |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
451 | } else { |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
452 | priv->scroll_time = NULL; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
453 | priv->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, priv, NULL); |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
454 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
455 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
456 | |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
457 | void gtk_webview_page_up(GtkWebView *webview) |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
458 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
459 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
460 | GtkAdjustment *vadj = priv->vadj; |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
461 | gdouble scroll_val; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
462 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
463 | #if GTK_CHECK_VERSION(2,14,0) |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
464 | scroll_val = gtk_adjustment_get_value(vadj) - gtk_adjustment_get_page_size(vadj); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
465 | scroll_val = MAX(scroll_val, gtk_adjustment_get_lower(vadj)); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
466 | #else |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
467 | scroll_val = gtk_adjustment_get_value(vadj) - vadj->page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
468 | scroll_val = MAX(scroll_val, vadj->lower); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
469 | #endif |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
470 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
471 | gtk_adjustment_set_value(vadj, scroll_val); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
472 | } |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
473 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
474 | void gtk_webview_page_down(GtkWebView *webview) |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
475 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
476 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
477 | GtkAdjustment *vadj = priv->vadj; |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
478 | gdouble scroll_val; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
479 | gdouble page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
480 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
481 | #if GTK_CHECK_VERSION(2,14,0) |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
482 | page_size = gtk_adjustment_get_page_size(vadj); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
483 | scroll_val = gtk_adjustment_get_value(vadj) + page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
484 | scroll_val = MIN(scroll_val, gtk_adjustment_get_upper(vadj) - page_size); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
485 | #else |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
486 | page_size = vadj->page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
487 | scroll_val = gtk_adjustment_get_value(vadj) + page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
488 | scroll_val = MIN(scroll_val, vadj->upper - page_size); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
489 | #endif |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
490 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
491 | gtk_adjustment_set_value(vadj, scroll_val); |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
492 | } |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
493 |