Sun, 03 Jun 2012 07:40:47 +0000
Setup WBFO in a WebView.
Though, really, I wish execCommand could work on arbitrary ranges
instead of needed to save and restore the selection.
| 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 | |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
31 | #include <gdk/gdkkeysyms.h> |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
32 | #include "gtkwebview.h" |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
33 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
34 | #define MAX_FONT_SIZE 7 |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
35 | #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
|
36 | #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
|
37 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
38 | #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
|
39 | (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
|
40 | |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
41 | enum { |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
42 | BUTTONS_UPDATE, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
43 | TOGGLE_FORMAT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
44 | CLEAR_FORMAT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
45 | UPDATE_FORMAT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
46 | LAST_SIGNAL |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
47 | }; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
48 | static guint signals[LAST_SIGNAL] = { 0 }; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
49 | |
|
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 | * Structs |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
52 | *****************************************************************************/ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
53 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | |
|
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
|
58 | /* 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
|
59 | 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
|
60 | 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
|
61 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
62 | /* Scroll adjustments */ |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
63 | GtkAdjustment *vadj; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
64 | guint scroll_src; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
65 | GTimer *scroll_time; |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
66 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
67 | /* Format options */ |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
68 | GtkWebViewButtons format_functions; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
69 | struct { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
70 | gboolean wbfo:1; /* Whole buffer formatting only. */ |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
71 | } edit; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
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 | } GtkWebViewPriv; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
74 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
75 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
76 | * Globals |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
77 | *****************************************************************************/ |
|
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
|
78 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
79 | 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
|
80 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
81 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
82 | * Helpers |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
83 | *****************************************************************************/ |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
84 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
85 | 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
|
86 | 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
|
87 | { |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
88 | char *src; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
89 | PurpleStoredImage *img; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
90 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
91 | 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
|
92 | /* 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
|
93 | 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
|
94 | if (src) |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
95 | return src; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
96 | } else { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
97 | 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
|
98 | 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
|
99 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
100 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
101 | /* 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
|
102 | 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
|
103 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
104 | 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
|
105 | if (src) { |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
106 | 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
|
107 | } else { |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
108 | char *tmp; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | g_free(tmp); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
113 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
114 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
115 | 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
|
116 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
117 | return src; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
118 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
119 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
120 | /* |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
121 | * 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
|
122 | * 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
|
123 | * purple changes the way it works. |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
124 | */ |
|
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 | static char * |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
126 | 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
|
127 | { |
|
32794
cf2f759f7010
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32793
diff
changeset
|
128 | GString *buffer = g_string_new(NULL); |
|
cf2f759f7010
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32793
diff
changeset
|
129 | const char *cur = html; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
130 | char *id; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
131 | int nid; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
132 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | g_string_append(buffer, cur); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
137 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
138 | } 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
|
139 | 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
|
140 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
141 | cur = strstr(img, "/>"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
142 | 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
|
143 | cur = strstr(img, ">"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
144 | |
| 32446 | 145 | 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
|
146 | 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
|
147 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
148 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
149 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
150 | 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
|
151 | 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
|
152 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
153 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
154 | |
| 32446 | 155 | /* |
| 156 | * if this is valid HTML, then I can be sure that it | |
| 157 | * has an id= and does not have an src=, since | |
| 158 | * '=' cannot appear in parameters. | |
| 159 | */ | |
| 160 | ||
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
161 | id = strstr(img, "id=") + 3; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
162 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
163 | /* *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
|
164 | 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
|
165 | 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
|
166 | else |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
167 | nid = atoi(id + 1); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
168 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
169 | /* 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
|
170 | 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
|
171 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
172 | 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
|
173 | } |
| 32446 | 174 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
175 | 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
|
176 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
177 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
178 | static gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
179 | 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
|
180 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
181 | 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
|
182 | 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
|
183 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
184 | 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
|
185 | 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
|
186 | 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
|
187 | 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
|
188 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
189 | 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
|
190 | 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
|
191 | g_free(script); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
192 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
193 | 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
|
194 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
195 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
196 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
197 | 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
|
198 | gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
199 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
200 | 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
|
201 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
202 | /* 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
|
203 | 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
|
204 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
205 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
206 | static void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
207 | 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
|
208 | gpointer userdata) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
209 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
210 | 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
|
211 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
212 | 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
|
213 | 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
|
214 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
215 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
216 | static gboolean |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
217 | 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
|
218 | WebKitWebFrame *frame, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
219 | WebKitNetworkRequest *request, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
220 | WebKitWebNavigationAction *navigation_action, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
221 | WebKitWebPolicyDecision *policy_decision, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
222 | gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
223 | { |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
224 | 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
|
225 | WebKitWebNavigationReason reason; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
226 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
227 | 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
|
228 | 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
|
229 | |
|
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
|
230 | 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
|
231 | /* 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
|
232 | * 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
|
233 | purple_notify_uri(NULL, uri); |
|
32800
67649fafdb51
If we handle a navigation request, then we should tell WebKit
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32799
diff
changeset
|
234 | webkit_web_policy_decision_ignore(policy_decision); |
|
32803
a2d80b30be13
We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32800
diff
changeset
|
235 | } else if (reason == WEBKIT_WEB_NAVIGATION_REASON_OTHER) |
|
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
|
236 | webkit_web_policy_decision_use(policy_decision); |
|
32803
a2d80b30be13
We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32800
diff
changeset
|
237 | else |
|
a2d80b30be13
We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32800
diff
changeset
|
238 | webkit_web_policy_decision_ignore(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
|
239 | |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
240 | return TRUE; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
241 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
242 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
243 | /* |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
244 | * 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
|
245 | * |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
246 | * @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
|
247 | */ |
|
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
|
248 | static gboolean |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
249 | 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
|
250 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
251 | GtkWebViewPriv *priv = data; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
252 | GtkAdjustment *adj; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
253 | gdouble max_val; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
254 | gdouble scroll_val; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
255 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
256 | 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
|
257 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
258 | adj = priv->vadj; |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
259 | #if GTK_CHECK_VERSION(2,14,0) |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
260 | max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
261 | #else |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
262 | max_val = adj->upper - adj->page_size; |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
263 | #endif |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
264 | 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
|
265 | ((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
|
266 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
267 | 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
|
268 | || 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
|
269 | /* 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
|
270 | 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
|
271 | 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
|
272 | 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
|
273 | 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
|
274 | 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
|
275 | return FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
276 | } |
|
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
|
277 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
278 | /* 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
|
279 | 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
|
280 | 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
|
281 | } |
|
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 | static gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
284 | 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
|
285 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
286 | GtkWebViewPriv *priv = data; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
287 | GtkAdjustment *adj = priv->vadj; |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
288 | gdouble max_val; |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
289 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
290 | if (adj) { |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
291 | #if GTK_CHECK_VERSION(2,14,0) |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
292 | max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
293 | #else |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
294 | max_val = adj->upper - adj->page_size; |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
295 | #endif |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
296 | gtk_adjustment_set_value(adj, max_val); |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
297 | } |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
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 | 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
|
300 | return FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
301 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
302 | |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
303 | static void |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
304 | webview_clear_formatting(GtkWebView *webview) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
305 | { |
|
32894
2bb8148a567a
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32872
diff
changeset
|
306 | WebKitDOMDocument *dom; |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
307 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
308 | if (!webkit_web_view_get_editable(WEBKIT_WEB_VIEW(webview))) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
309 | return; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
310 | |
|
32894
2bb8148a567a
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32872
diff
changeset
|
311 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
2bb8148a567a
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32872
diff
changeset
|
312 | webkit_dom_document_exec_command(dom, "removeFormat", FALSE, ""); |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
313 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
314 | |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
315 | static void |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
316 | webview_toggle_format(GtkWebView *webview, GtkWebViewButtons buttons) |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
317 | { |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
318 | /* since this function is the handler for the formatting keystrokes, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
319 | we need to check here that the formatting attempted is permitted */ |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
320 | buttons &= gtk_webview_get_format_functions(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
321 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
322 | switch (buttons) { |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
323 | case GTK_WEBVIEW_BOLD: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
324 | gtk_webview_toggle_bold(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
325 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
326 | case GTK_WEBVIEW_ITALIC: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
327 | gtk_webview_toggle_italic(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
328 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
329 | case GTK_WEBVIEW_UNDERLINE: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
330 | gtk_webview_toggle_underline(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
331 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
332 | case GTK_WEBVIEW_STRIKE: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
333 | gtk_webview_toggle_strike(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
334 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
335 | case GTK_WEBVIEW_SHRINK: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
336 | gtk_webview_font_shrink(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
337 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
338 | case GTK_WEBVIEW_GROW: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
339 | gtk_webview_font_grow(webview); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
340 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
341 | default: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
342 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
343 | } |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
344 | } |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
345 | |
|
32796
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 | * GObject Stuff |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
348 | *****************************************************************************/ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
349 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
350 | GtkWidget * |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
351 | 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
|
352 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
353 | 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
|
354 | } |
|
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
|
355 | |
|
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
|
356 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
357 | 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
|
358 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
359 | 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
|
360 | gpointer temp; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
361 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
362 | 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
|
363 | g_free(temp); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
364 | 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
|
365 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
366 | if (priv->images) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
367 | 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
|
368 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
369 | 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
|
370 | } |
|
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
|
371 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
372 | static void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
373 | 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
|
374 | { |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
375 | GObjectClass *gobject_class; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
376 | GtkBindingSet *binding_set; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
377 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
378 | parent_class = g_type_class_ref(webkit_web_view_get_type()); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
379 | gobject_class = G_OBJECT_CLASS(klass); |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
380 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
381 | 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
|
382 | |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
383 | signals[BUTTONS_UPDATE] = g_signal_new("allowed-formats-updated", |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
384 | G_TYPE_FROM_CLASS(gobject_class), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
385 | G_SIGNAL_RUN_FIRST, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
386 | G_STRUCT_OFFSET(GtkWebViewClass, buttons_update), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
387 | NULL, 0, g_cclosure_marshal_VOID__INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
388 | G_TYPE_NONE, 1, G_TYPE_INT); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
389 | signals[TOGGLE_FORMAT] = g_signal_new("format-toggled", |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
390 | G_TYPE_FROM_CLASS(gobject_class), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
391 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
392 | G_STRUCT_OFFSET(GtkWebViewClass, toggle_format), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
393 | NULL, 0, g_cclosure_marshal_VOID__INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
394 | G_TYPE_NONE, 1, G_TYPE_INT); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
395 | signals[CLEAR_FORMAT] = g_signal_new("format-cleared", |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
396 | G_TYPE_FROM_CLASS(gobject_class), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
397 | G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
398 | G_STRUCT_OFFSET(GtkWebViewClass, clear_format), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
399 | NULL, 0, g_cclosure_marshal_VOID__VOID, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
400 | G_TYPE_NONE, 0); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
401 | signals[UPDATE_FORMAT] = g_signal_new("format-updated", |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
402 | G_TYPE_FROM_CLASS(gobject_class), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
403 | G_SIGNAL_RUN_FIRST, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
404 | G_STRUCT_OFFSET(GtkWebViewClass, update_format), |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
405 | NULL, 0, g_cclosure_marshal_VOID__VOID, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
406 | G_TYPE_NONE, 0); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
407 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
408 | klass->toggle_format = webview_toggle_format; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
409 | klass->clear_format = webview_clear_formatting; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
410 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
411 | gobject_class->finalize = gtk_webview_finalize; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
412 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
413 | binding_set = gtk_binding_set_by_class(parent_class); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
414 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_b, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
415 | "format-toggled", 1, G_TYPE_INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
416 | GTK_WEBVIEW_BOLD); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
417 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_i, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
418 | "format-toggled", 1, G_TYPE_INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
419 | GTK_WEBVIEW_ITALIC); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
420 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_u, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
421 | "format-toggled", 1, G_TYPE_INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
422 | GTK_WEBVIEW_UNDERLINE); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
423 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_plus, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
424 | "format-toggled", 1, G_TYPE_INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
425 | GTK_WEBVIEW_GROW); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
426 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_equal, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
427 | "format-toggled", 1, G_TYPE_INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
428 | GTK_WEBVIEW_GROW); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
429 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_minus, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
430 | "format-toggled", 1, G_TYPE_INT, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
431 | GTK_WEBVIEW_SHRINK); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
432 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
433 | binding_set = gtk_binding_set_by_class(klass); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
434 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_r, GDK_CONTROL_MASK, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
435 | "format-cleared", 0); |
|
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
|
436 | } |
|
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
|
437 | |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
438 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
439 | 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
|
440 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
441 | 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
|
442 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
443 | priv->empty = TRUE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
444 | 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
|
445 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
446 | g_signal_connect(webview, "navigation-policy-decision-requested", |
|
32799
918d0fc9a651
Passing the webview as userdata when the webview is the object
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32797
diff
changeset
|
447 | G_CALLBACK(webview_link_clicked), 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
|
448 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
449 | g_signal_connect(webview, "load-started", |
|
32799
918d0fc9a651
Passing the webview as userdata when the webview is the object
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32797
diff
changeset
|
450 | G_CALLBACK(webview_load_started), 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
|
451 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
452 | g_signal_connect(webview, "load-finished", |
|
32799
918d0fc9a651
Passing the webview as userdata when the webview is the object
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32797
diff
changeset
|
453 | G_CALLBACK(webview_load_finished), NULL); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
454 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
455 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
456 | GType |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
457 | gtk_webview_get_type(void) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
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 | 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
|
460 | 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
|
461 | 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
|
462 | sizeof(GtkWebViewClass), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
463 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
464 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
465 | (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
|
466 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
467 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
468 | sizeof(GtkWebView), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
469 | 0, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
470 | (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
|
471 | NULL |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
472 | }; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
473 | 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
|
474 | "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
|
475 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
476 | return mview_type; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
477 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
478 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
479 | /***************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
480 | * Public API functions |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
481 | *****************************************************************************/ |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
482 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
483 | gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
484 | 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
|
485 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
486 | 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
|
487 | return priv->empty; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
488 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
489 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
490 | char * |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
491 | 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
|
492 | { |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
493 | 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
|
494 | const char *cur = text; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
495 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
496 | 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
|
497 | 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
|
498 | case '\\': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
499 | 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
|
500 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
501 | case '\"': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
502 | 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
|
503 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
504 | 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
|
505 | 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
|
506 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
507 | 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
|
508 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
509 | default: |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
510 | 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
|
511 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
512 | cur++; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
513 | } |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
514 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
515 | 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
|
516 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
517 | 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
|
518 | } |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
519 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
520 | void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
521 | 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
|
522 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
523 | 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
|
524 | 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
|
525 | 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
|
526 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
527 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
528 | void |
|
32993
d6da54acf528
Remove _with_imgstore suffix on this function. There isn't a version
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32898
diff
changeset
|
529 | gtk_webview_load_html_string(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
|
530 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
531 | 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
|
532 | char *html_imged; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
533 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
534 | if (priv->images) { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
535 | 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
|
536 | priv->images = NULL; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
537 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
538 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
539 | 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
|
540 | 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
|
541 | NULL, "file:///"); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
542 | g_free(html_imged); |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
543 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
544 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
545 | /* 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
|
546 | * 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
|
547 | * 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
|
548 | * wrong to hardcode that here. |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
549 | */ |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
550 | void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
551 | 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
|
552 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
553 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
32994
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
554 | WebKitDOMDocument *doc; |
|
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
555 | WebKitDOMHTMLElement *body; |
|
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
556 | doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
557 | body = webkit_dom_document_get_body(doc); |
|
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
558 | webkit_dom_html_element_insert_adjacent_html(body, "beforeend", html, NULL); |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
559 | priv->empty = FALSE; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
560 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
561 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
562 | void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
563 | 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
|
564 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
565 | 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
|
566 | priv->vadj = vadj; |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
567 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
568 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
569 | void |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
570 | 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
|
571 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
572 | 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
|
573 | if (priv->scroll_time) |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
574 | 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
|
575 | if (priv->scroll_src) |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
576 | 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
|
577 | if (smooth) { |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
578 | 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
|
579 | 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
|
580 | } else { |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
581 | priv->scroll_time = NULL; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
582 | 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
|
583 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
584 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
585 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
586 | void |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
587 | gtk_webview_page_up(GtkWebView *webview) |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
588 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
589 | 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
|
590 | GtkAdjustment *vadj = priv->vadj; |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
591 | gdouble scroll_val; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
592 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
593 | #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
|
594 | 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
|
595 | 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
|
596 | #else |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
597 | 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
|
598 | 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
|
599 | #endif |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
600 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
601 | 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
|
602 | } |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
603 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
604 | void |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
605 | gtk_webview_page_down(GtkWebView *webview) |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
606 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
607 | 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
|
608 | GtkAdjustment *vadj = priv->vadj; |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
609 | gdouble scroll_val; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
610 | gdouble page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
611 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
612 | #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
|
613 | 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
|
614 | 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
|
615 | 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
|
616 | #else |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
617 | page_size = vadj->page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
618 | 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
|
619 | 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
|
620 | #endif |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
621 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
622 | 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
|
623 | } |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
624 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
625 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
626 | gtk_webview_set_editable(GtkWebView *webview, gboolean editable) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
627 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
628 | webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable); |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
629 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
630 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
631 | void |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
632 | gtk_webview_setup_entry(GtkWebView *webview, PurpleConnectionFlags flags) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
633 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
634 | GtkWebViewButtons buttons; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
635 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
636 | if (flags & PURPLE_CONNECTION_HTML) { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
637 | char color[8]; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
638 | GdkColor fg_color, bg_color; |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
639 | gboolean bold, italic, underline, strike; |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
640 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
641 | buttons = GTK_WEBVIEW_ALL; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
642 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
643 | if (flags & PURPLE_CONNECTION_NO_BGCOLOR) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
644 | buttons &= ~GTK_WEBVIEW_BACKCOLOR; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
645 | if (flags & PURPLE_CONNECTION_NO_FONTSIZE) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
646 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
647 | buttons &= ~GTK_WEBVIEW_GROW; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
648 | buttons &= ~GTK_WEBVIEW_SHRINK; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
649 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
650 | if (flags & PURPLE_CONNECTION_NO_URLDESC) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
651 | buttons &= ~GTK_WEBVIEW_LINKDESC; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
652 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
653 | gtk_webview_get_current_format(webview, &bold, &italic, &underline, &strike); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
654 | |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
655 | gtk_webview_set_format_functions(webview, GTK_WEBVIEW_ALL); |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
656 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != bold) |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
657 | gtk_webview_toggle_bold(webview); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
658 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
659 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != italic) |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
660 | gtk_webview_toggle_italic(webview); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
661 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
662 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != underline) |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
663 | gtk_webview_toggle_underline(webview); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
664 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
665 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike") != strike) |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
666 | gtk_webview_toggle_strike(webview); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
667 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
668 | gtk_webview_toggle_fontface(webview, |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
669 | purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face")); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
670 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
671 | if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE)) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
672 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
673 | int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size"); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
674 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
675 | /* 3 is the default. */ |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
676 | if (size != 3) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
677 | gtk_webview_font_set_size(webview, size); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
678 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
679 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
680 | if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
681 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
682 | gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
683 | &fg_color); |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
684 | g_snprintf(color, sizeof(color), |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
685 | "#%02x%02x%02x", |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
686 | fg_color.red / 256, |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
687 | fg_color.green / 256, |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
688 | fg_color.blue / 256); |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
689 | } else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
690 | strcpy(color, ""); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
691 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
692 | gtk_webview_toggle_forecolor(webview, color); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
693 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
694 | if (!(flags & PURPLE_CONNECTION_NO_BGCOLOR) && |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
695 | strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0) |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
696 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
697 | gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
698 | &bg_color); |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
699 | g_snprintf(color, sizeof(color), |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
700 | "#%02x%02x%02x", |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
701 | bg_color.red / 256, |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
702 | bg_color.green / 256, |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
703 | bg_color.blue / 256); |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
704 | } else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
705 | strcpy(color, ""); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
706 | |
|
32896
a9cbf3a55393
Having a backcolor and a background seems a bit redundant. And we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32895
diff
changeset
|
707 | gtk_webview_toggle_backcolor(webview, color); |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
708 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
709 | if (flags & PURPLE_CONNECTION_FORMATTING_WBFO) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
710 | gtk_webview_set_whole_buffer_formatting_only(webview, TRUE); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
711 | else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
712 | gtk_webview_set_whole_buffer_formatting_only(webview, FALSE); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
713 | } else { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
714 | buttons = GTK_WEBVIEW_SMILEY | GTK_WEBVIEW_IMAGE; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
715 | webview_clear_formatting(webview); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
716 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
717 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
718 | if (flags & PURPLE_CONNECTION_NO_IMAGES) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
719 | buttons &= ~GTK_WEBVIEW_IMAGE; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
720 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
721 | if (flags & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
722 | buttons |= GTK_WEBVIEW_CUSTOM_SMILEY; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
723 | else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
724 | buttons &= ~GTK_WEBVIEW_CUSTOM_SMILEY; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
725 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
726 | gtk_webview_set_format_functions(webview, buttons); |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
727 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
728 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
729 | void |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
730 | gtk_webview_set_whole_buffer_formatting_only(GtkWebView *webview, gboolean wbfo) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
731 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
732 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
733 | priv->edit.wbfo = wbfo; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
734 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
735 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
736 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
737 | gtk_webview_set_format_functions(GtkWebView *webview, GtkWebViewButtons buttons) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
738 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
739 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
32812
5be5c09c86de
Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32811
diff
changeset
|
740 | GObject *object = g_object_ref(G_OBJECT(webview)); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
741 | priv->format_functions = buttons; |
|
32812
5be5c09c86de
Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32811
diff
changeset
|
742 | g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
|
5be5c09c86de
Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32811
diff
changeset
|
743 | g_object_unref(object); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
744 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
745 | |
|
33004
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
746 | gchar * |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
747 | gtk_webview_get_head_html(GtkWebView *webview) |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
748 | { |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
749 | WebKitDOMDocument *doc; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
750 | WebKitDOMHTMLHeadElement *head; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
751 | gchar *html; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
752 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
753 | doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
754 | head = webkit_dom_document_get_head(doc); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
755 | html = webkit_dom_html_element_get_inner_html(WEBKIT_DOM_HTML_ELEMENT(head)); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
756 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
757 | return html; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
758 | } |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
759 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
760 | gchar * |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
761 | gtk_webview_get_body_html(GtkWebView *webview) |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
762 | { |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
763 | WebKitDOMDocument *doc; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
764 | WebKitDOMHTMLElement *body; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
765 | gchar *html; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
766 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
767 | doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
768 | body = webkit_dom_document_get_body(doc); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
769 | html = webkit_dom_html_element_get_inner_html(body); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
770 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
771 | return html; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
772 | } |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
773 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
774 | gchar * |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
775 | gtk_webview_get_body_text(GtkWebView *webview) |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
776 | { |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
777 | WebKitDOMDocument *doc; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
778 | WebKitDOMHTMLElement *body; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
779 | gchar *text; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
780 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
781 | doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
782 | body = webkit_dom_document_get_body(doc); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
783 | text = webkit_dom_html_element_get_inner_text(body); |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
784 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
785 | return text; |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
786 | } |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
787 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
788 | GtkWebViewButtons |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
789 | gtk_webview_get_format_functions(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
790 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
791 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
792 | return priv->format_functions; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
793 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
794 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
795 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
796 | gtk_webview_get_current_format(GtkWebView *webview, gboolean *bold, |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
797 | gboolean *italic, gboolean *underline, |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
798 | gboolean *strike) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
799 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
800 | WebKitDOMDocument *dom; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
801 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
802 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
803 | if (bold) |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
804 | *bold = webkit_dom_document_query_command_state(dom, "bold"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
805 | if (italic) |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
806 | *italic = webkit_dom_document_query_command_state(dom, "italic"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
807 | if (underline) |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
808 | *underline = webkit_dom_document_query_command_state(dom, "underline"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
809 | if (strike) |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
810 | *strike = webkit_dom_document_query_command_state(dom, "strikethrough"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
811 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
812 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
813 | char * |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
814 | gtk_webview_get_current_fontface(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
815 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
816 | WebKitDOMDocument *dom; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
817 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
818 | return webkit_dom_document_query_command_value(dom, "fontName"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
819 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
820 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
821 | char * |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
822 | gtk_webview_get_current_forecolor(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
823 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
824 | WebKitDOMDocument *dom; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
825 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
826 | return webkit_dom_document_query_command_value(dom, "foreColor"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
827 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
828 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
829 | char * |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
830 | gtk_webview_get_current_backcolor(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
831 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
832 | WebKitDOMDocument *dom; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
833 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
834 | return webkit_dom_document_query_command_value(dom, "backColor"); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
835 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
836 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
837 | gint |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
838 | gtk_webview_get_current_fontsize(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
839 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
840 | WebKitDOMDocument *dom; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
841 | gchar *text; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
842 | gint size; |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
843 | |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
844 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
845 | text = webkit_dom_document_query_command_value(dom, "fontSize"); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
846 | size = atoi(text); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
847 | g_free(text); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
848 | |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
849 | return size; |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
850 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
851 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
852 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
853 | gtk_webview_get_editable(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
854 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
855 | return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(webview)); |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
856 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
857 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
858 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
859 | gtk_webview_clear_formatting(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
860 | { |
|
32813
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
861 | GObject *object; |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
862 | |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
863 | object = g_object_ref(G_OBJECT(webview)); |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
864 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
865 | |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
866 | gtk_widget_grab_focus(GTK_WIDGET(webview)); |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
867 | |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
868 | g_object_unref(object); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
869 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
870 | |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
871 | static void |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
872 | do_formatting(GtkWebView *webview, const char *name, const char *value) |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
873 | { |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
874 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
875 | WebKitDOMDocument *dom; |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
876 | WebKitDOMDOMWindow *win = NULL; |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
877 | WebKitDOMDOMSelection *sel; |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
878 | WebKitDOMRange *range = NULL; |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
879 | |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
880 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
881 | |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
882 | if (priv->edit.wbfo) { |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
883 | win = webkit_dom_document_get_default_view(dom); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
884 | sel = webkit_dom_dom_window_get_selection(win); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
885 | range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
886 | webkit_web_view_select_all(WEBKIT_WEB_VIEW(webview)); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
887 | } |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
888 | |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
889 | webkit_dom_document_exec_command(dom, name, FALSE, value); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
890 | |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
891 | if (priv->edit.wbfo) { |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
892 | sel = webkit_dom_dom_window_get_selection(win); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
893 | webkit_dom_dom_selection_remove_all_ranges(sel); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
894 | webkit_dom_dom_selection_add_range(sel, range); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
895 | } |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
896 | } |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
897 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
898 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
899 | gtk_webview_toggle_bold(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
900 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
901 | do_formatting(webview, "bold", ""); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
902 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
903 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
904 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
905 | gtk_webview_toggle_italic(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
906 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
907 | do_formatting(webview, "italic", ""); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
908 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
909 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
910 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
911 | gtk_webview_toggle_underline(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
912 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
913 | do_formatting(webview, "underline", ""); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
914 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
915 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
916 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
917 | gtk_webview_toggle_strike(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
918 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
919 | do_formatting(webview, "strikethrough", ""); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
920 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
921 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
922 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
923 | gtk_webview_toggle_forecolor(GtkWebView *webview, const char *color) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
924 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
925 | do_formatting(webview, "foreColor", color); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
926 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
927 | return FALSE; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
928 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
929 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
930 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
931 | gtk_webview_toggle_backcolor(GtkWebView *webview, const char *color) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
932 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
933 | do_formatting(webview, "backColor", color); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
934 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
935 | return FALSE; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
936 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
937 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
938 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
939 | gtk_webview_toggle_fontface(GtkWebView *webview, const char *face) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
940 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
941 | do_formatting(webview, "fontName", face); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
942 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
943 | return FALSE; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
944 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
945 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
946 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
947 | gtk_webview_font_set_size(GtkWebView *webview, gint size) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
948 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
949 | char *tmp = g_strdup_printf("%d", size); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
950 | do_formatting(webview, "fontSize", tmp); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
951 | g_free(tmp); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
952 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
953 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
954 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
955 | gtk_webview_font_shrink(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
956 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
957 | gint fontsize; |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
958 | char *tmp; |
|
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
959 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
960 | fontsize = gtk_webview_get_current_fontsize(webview); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
961 | fontsize = MAX(fontsize - 1, 1); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
962 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
963 | tmp = g_strdup_printf("%d", fontsize); |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
964 | do_formatting(webview, "fontSize", tmp); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
965 | g_free(tmp); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
966 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
967 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
968 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
969 | gtk_webview_font_grow(GtkWebView *webview) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
970 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
971 | gint fontsize; |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
972 | char *tmp; |
|
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
973 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
974 | fontsize = gtk_webview_get_current_fontsize(webview); |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
975 | fontsize = MIN(fontsize + 1, MAX_FONT_SIZE); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
976 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
977 | tmp = g_strdup_printf("%d", fontsize); |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
978 | do_formatting(webview, "fontSize", tmp); |
|
32823
f179695f60cb
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32813
diff
changeset
|
979 | g_free(tmp); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
980 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
981 |