Wed, 06 Jun 2012 02:56:53 +0000
This focus grab seems to be in the wrong place.
| 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, |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
46 | CHANGED, |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
47 | LAST_SIGNAL |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
48 | }; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
49 | 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
|
50 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
51 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
52 | * Structs |
|
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 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | |
|
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 | /* 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
|
60 | 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
|
61 | 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
|
62 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
63 | /* Scroll adjustments */ |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
64 | GtkAdjustment *vadj; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
65 | guint scroll_src; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
66 | 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
|
67 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
68 | /* Format options */ |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
69 | GtkWebViewButtons format_functions; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
70 | struct { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
71 | gboolean wbfo:1; /* Whole buffer formatting only. */ |
|
33010
aa658ddce5ec
Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33009
diff
changeset
|
72 | gboolean block_changed:1; |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
73 | } edit; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
74 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
75 | } GtkWebViewPriv; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
76 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
77 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
78 | * Globals |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
79 | *****************************************************************************/ |
|
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
|
80 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
81 | 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
|
82 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
83 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
84 | * Helpers |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
85 | *****************************************************************************/ |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
86 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
87 | 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
|
88 | 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
|
89 | { |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
90 | char *src; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
91 | PurpleStoredImage *img; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
92 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
93 | 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
|
94 | /* 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
|
95 | 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
|
96 | if (src) |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
97 | return src; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
98 | } else { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
99 | 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
|
100 | 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
|
101 | } |
|
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 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
103 | /* 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
|
104 | 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
|
105 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
106 | 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
|
107 | if (src) { |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
108 | 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
|
109 | } else { |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
110 | char *tmp; |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
111 | 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
|
112 | 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
|
113 | 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
|
114 | g_free(tmp); |
|
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
115 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
116 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
117 | 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
|
118 | |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
119 | return src; |
|
32441
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 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
122 | /* |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
123 | * 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
|
124 | * 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
|
125 | * purple changes the way it works. |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
126 | */ |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
127 | static char * |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
128 | 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
|
129 | { |
|
32794
cf2f759f7010
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32793
diff
changeset
|
130 | GString *buffer = g_string_new(NULL); |
|
cf2f759f7010
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32793
diff
changeset
|
131 | const char *cur = html; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
132 | char *id; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
133 | int nid; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
134 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | g_string_append(buffer, cur); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
139 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
140 | } 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
|
141 | 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
|
142 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
143 | cur = strstr(img, "/>"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
144 | 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
|
145 | cur = strstr(img, ">"); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
146 | |
| 32446 | 147 | 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
|
148 | 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
|
149 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
150 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
151 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
152 | 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
|
153 | 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
|
154 | break; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
155 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
156 | |
| 32446 | 157 | /* |
| 158 | * if this is valid HTML, then I can be sure that it | |
| 159 | * has an id= and does not have an src=, since | |
| 160 | * '=' cannot appear in parameters. | |
| 161 | */ | |
| 162 | ||
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
163 | id = strstr(img, "id=") + 3; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
164 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
165 | /* *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
|
166 | 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
|
167 | 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
|
168 | else |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
169 | nid = atoi(id + 1); |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
170 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
171 | /* 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
|
172 | 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
|
173 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
174 | 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
|
175 | } |
| 32446 | 176 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
177 | 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
|
178 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
179 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
180 | static gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
181 | 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
|
182 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
183 | 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
|
184 | 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
|
185 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
186 | 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
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
191 | 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
|
192 | 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
|
193 | g_free(script); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
194 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
195 | 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
|
196 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
197 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
198 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
199 | 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
|
200 | gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
201 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
202 | 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
|
203 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
204 | /* 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
|
205 | 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
|
206 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
207 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
208 | static void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
209 | 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
|
210 | gpointer userdata) |
|
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 | 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
|
213 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
214 | 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
|
215 | 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
|
216 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
217 | |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
218 | static gboolean |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
219 | 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
|
220 | WebKitWebFrame *frame, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
221 | WebKitNetworkRequest *request, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
222 | WebKitWebNavigationAction *navigation_action, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
223 | WebKitWebPolicyDecision *policy_decision, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
224 | gpointer userdata) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
225 | { |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
226 | 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
|
227 | WebKitWebNavigationReason reason; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
228 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
229 | 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
|
230 | 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
|
231 | |
|
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
|
232 | 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
|
233 | /* 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
|
234 | * 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
|
235 | 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
|
236 | 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
|
237 | } 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
|
238 | 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
|
239 | 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
|
240 | 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
|
241 | |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
242 | return TRUE; |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
243 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
244 | |
|
32796
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 | * 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
|
247 | * |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
248 | * @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
|
249 | */ |
|
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 | static gboolean |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
251 | 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
|
252 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
253 | GtkWebViewPriv *priv = data; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
254 | GtkAdjustment *adj; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
255 | gdouble max_val; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
256 | gdouble scroll_val; |
|
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 | 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
|
259 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
260 | adj = priv->vadj; |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
261 | #if GTK_CHECK_VERSION(2,14,0) |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
262 | 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
|
263 | #else |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
264 | 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
|
265 | #endif |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
266 | 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
|
267 | ((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
|
268 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
269 | 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
|
270 | || 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
|
271 | /* 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
|
272 | 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
|
273 | 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
|
274 | 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
|
275 | 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
|
276 | 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
|
277 | return FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
278 | } |
|
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
|
279 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
280 | /* 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
|
281 | 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
|
282 | 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
|
283 | } |
|
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
|
284 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
285 | static gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
286 | 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
|
287 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
288 | GtkWebViewPriv *priv = data; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
289 | GtkAdjustment *adj = priv->vadj; |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
290 | gdouble max_val; |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
291 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
292 | if (adj) { |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
293 | #if GTK_CHECK_VERSION(2,14,0) |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
294 | 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
|
295 | #else |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
296 | max_val = adj->upper - adj->page_size; |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
297 | #endif |
|
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
298 | 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
|
299 | } |
|
32797
3fe407409ec2
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32796
diff
changeset
|
300 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
301 | 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
|
302 | return FALSE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
303 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
304 | |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
305 | static void |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
306 | emit_format_signal(GtkWebView *webview, GtkWebViewButtons buttons) |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
307 | { |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
308 | g_object_ref(webview); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
309 | g_signal_emit(webview, signals[TOGGLE_FORMAT], 0, buttons); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
310 | g_object_unref(webview); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
311 | } |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
312 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
313 | static void |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
314 | do_formatting(GtkWebView *webview, const char *name, const char *value) |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
315 | { |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
316 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
317 | WebKitDOMDocument *dom; |
|
33022
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
318 | WebKitDOMDOMWindow *win; |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
319 | WebKitDOMDOMSelection *sel = NULL; |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
320 | WebKitDOMRange *range = NULL; |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
321 | |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
322 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
323 | |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
324 | if (priv->edit.wbfo) { |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
325 | win = webkit_dom_document_get_default_view(dom); |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
326 | sel = webkit_dom_dom_window_get_selection(win); |
|
33022
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
327 | if (webkit_dom_dom_selection_get_range_count(sel) > 0) |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
328 | range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL); |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
329 | webkit_web_view_select_all(WEBKIT_WEB_VIEW(webview)); |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
330 | } |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
331 | |
|
33010
aa658ddce5ec
Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33009
diff
changeset
|
332 | priv->edit.block_changed = TRUE; |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
333 | webkit_dom_document_exec_command(dom, name, FALSE, value); |
|
33010
aa658ddce5ec
Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33009
diff
changeset
|
334 | priv->edit.block_changed = FALSE; |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
335 | |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
336 | if (priv->edit.wbfo) { |
|
33022
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
337 | if (range) { |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
338 | webkit_dom_dom_selection_remove_all_ranges(sel); |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
339 | webkit_dom_dom_selection_add_range(sel, range); |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
340 | } else { |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
341 | webkit_dom_dom_selection_collapse_to_end(sel, NULL); |
|
87c277f64c4e
Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33021
diff
changeset
|
342 | } |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
343 | } |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
344 | } |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
345 | |
|
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
346 | static void |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
347 | webview_font_shrink(GtkWebView *webview) |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
348 | { |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
349 | gint fontsize; |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
350 | char *tmp; |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
351 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
352 | fontsize = gtk_webview_get_current_fontsize(webview); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
353 | fontsize = MAX(fontsize - 1, 1); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
354 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
355 | tmp = g_strdup_printf("%d", fontsize); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
356 | do_formatting(webview, "fontSize", tmp); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
357 | g_free(tmp); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
358 | } |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
359 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
360 | static void |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
361 | webview_font_grow(GtkWebView *webview) |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
362 | { |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
363 | gint fontsize; |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
364 | char *tmp; |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
365 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
366 | fontsize = gtk_webview_get_current_fontsize(webview); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
367 | fontsize = MIN(fontsize + 1, MAX_FONT_SIZE); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
368 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
369 | tmp = g_strdup_printf("%d", fontsize); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
370 | do_formatting(webview, "fontSize", tmp); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
371 | g_free(tmp); |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
372 | } |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
373 | |
|
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
374 | static 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
|
375 | 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
|
376 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
377 | 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
|
378 | return; |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
379 | |
|
33009
364b314b125a
Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33008
diff
changeset
|
380 | do_formatting(webview, "removeFormat", ""); |
|
33020
03c013f8990c
Remove links and background colours on format-clear.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33018
diff
changeset
|
381 | do_formatting(webview, "unlink", ""); |
|
03c013f8990c
Remove links and background colours on format-clear.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33018
diff
changeset
|
382 | do_formatting(webview, "backColor", "inherit"); |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
383 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
384 | |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
385 | static void |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
386 | 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
|
387 | { |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
388 | /* 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
|
389 | 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
|
390 | 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
|
391 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
392 | switch (buttons) { |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
393 | case GTK_WEBVIEW_BOLD: |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
394 | do_formatting(webview, "bold", ""); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
395 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
396 | case GTK_WEBVIEW_ITALIC: |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
397 | do_formatting(webview, "italic", ""); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
398 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
399 | case GTK_WEBVIEW_UNDERLINE: |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
400 | do_formatting(webview, "underline", ""); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
401 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
402 | case GTK_WEBVIEW_STRIKE: |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
403 | do_formatting(webview, "strikethrough", ""); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
404 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
405 | case GTK_WEBVIEW_SHRINK: |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
406 | webview_font_shrink(webview); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
407 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
408 | case GTK_WEBVIEW_GROW: |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
409 | webview_font_grow(webview); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
410 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
411 | default: |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
412 | break; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
413 | } |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
414 | } |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
415 | |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
416 | static void |
|
33008
b1811b11f907
Fix parameters to input signal handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33007
diff
changeset
|
417 | editable_input_cb(GObject *target, WebKitDOMEvent *event, GtkWebView *webview) |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
418 | { |
|
33010
aa658ddce5ec
Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33009
diff
changeset
|
419 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
aa658ddce5ec
Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33009
diff
changeset
|
420 | if (!priv->edit.block_changed) |
|
aa658ddce5ec
Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33009
diff
changeset
|
421 | g_signal_emit(webview, signals[CHANGED], 0); |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
422 | } |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
423 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
424 | /****************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
425 | * GObject Stuff |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
426 | *****************************************************************************/ |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
427 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
428 | GtkWidget * |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
429 | 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
|
430 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
431 | 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
|
432 | } |
|
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
|
433 | |
|
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
|
434 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
435 | 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
|
436 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
437 | 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
|
438 | gpointer temp; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
439 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
440 | 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
|
441 | g_free(temp); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
442 | 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
|
443 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
444 | if (priv->images) |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
445 | 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
|
446 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
447 | 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
|
448 | } |
|
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
|
449 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
450 | static void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
451 | 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
|
452 | { |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
453 | GObjectClass *gobject_class; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
454 | GtkBindingSet *binding_set; |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
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 | 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
|
457 | 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
|
458 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
459 | 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
|
460 | |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
461 | 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
|
462 | 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
|
463 | G_SIGNAL_RUN_FIRST, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
464 | 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
|
465 | 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
|
466 | 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
|
467 | 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
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | 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
|
478 | G_TYPE_NONE, 0); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
479 | 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
|
480 | 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
|
481 | G_SIGNAL_RUN_FIRST, |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
482 | 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
|
483 | 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
|
484 | G_TYPE_NONE, 0); |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
485 | signals[CHANGED] = g_signal_new("changed", |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
486 | G_TYPE_FROM_CLASS(gobject_class), |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
487 | G_SIGNAL_RUN_FIRST, |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
488 | G_STRUCT_OFFSET(GtkWebViewClass, changed), |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
489 | NULL, NULL, g_cclosure_marshal_VOID__VOID, |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
490 | G_TYPE_NONE, 0); |
|
32811
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
491 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
492 | 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
|
493 | 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
|
494 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
495 | 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
|
496 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
497 | 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
|
498 | 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
|
499 | "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
|
500 | GTK_WEBVIEW_BOLD); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
501 | 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
|
502 | "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
|
503 | GTK_WEBVIEW_ITALIC); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
504 | 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
|
505 | "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
|
506 | GTK_WEBVIEW_UNDERLINE); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
507 | 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
|
508 | "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
|
509 | GTK_WEBVIEW_GROW); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
510 | 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
|
511 | "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
|
512 | GTK_WEBVIEW_GROW); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
513 | 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
|
514 | "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
|
515 | GTK_WEBVIEW_SHRINK); |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
516 | |
|
87c1f3bb5461
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32810
diff
changeset
|
517 | 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
|
518 | 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
|
519 | "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
|
520 | } |
|
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
|
521 | |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
522 | static void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
523 | 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
|
524 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
525 | 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
|
526 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
527 | priv->empty = TRUE; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
528 | 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
|
529 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
530 | 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
|
531 | 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
|
532 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
533 | 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
|
534 | 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
|
535 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
536 | 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
|
537 | 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
|
538 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
539 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
540 | GType |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
541 | gtk_webview_get_type(void) |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
542 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | sizeof(GtkWebViewClass), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
547 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
548 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
549 | (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
|
550 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
551 | NULL, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
552 | sizeof(GtkWebView), |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
553 | 0, |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
554 | (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
|
555 | NULL |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
556 | }; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
557 | 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
|
558 | "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
|
559 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
560 | return mview_type; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
561 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
562 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
563 | /***************************************************************************** |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
564 | * Public API functions |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
565 | *****************************************************************************/ |
|
32793
db876e8e41ac
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32791
diff
changeset
|
566 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
567 | gboolean |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
568 | 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
|
569 | { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
570 | 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
|
571 | return priv->empty; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
572 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
573 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
574 | char * |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
575 | 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
|
576 | { |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
577 | 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
|
578 | const char *cur = text; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
579 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
580 | 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
|
581 | 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
|
582 | case '\\': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
583 | 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
|
584 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
585 | case '\"': |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
586 | 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
|
587 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
588 | 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
|
589 | 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
|
590 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
591 | 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
|
592 | break; |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
593 | default: |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
594 | 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
|
595 | } |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
596 | cur++; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
597 | } |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
598 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
599 | 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
|
600 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
601 | 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
|
602 | } |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
603 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
604 | void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
605 | 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
|
606 | { |
|
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 | 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
|
609 | 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
|
610 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
611 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
612 | 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
|
613 | 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
|
614 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
615 | 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
|
616 | char *html_imged; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
617 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
618 | if (priv->images) { |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
619 | 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
|
620 | priv->images = NULL; |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
621 | } |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
622 | |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
623 | 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
|
624 | 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
|
625 | NULL, "file:///"); |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
626 | g_free(html_imged); |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
627 | } |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
628 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
629 | /* 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
|
630 | * 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
|
631 | * 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
|
632 | * wrong to hardcode that here. |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
633 | */ |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
634 | void |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
635 | 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
|
636 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
637 | 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
|
638 | WebKitDOMDocument *doc; |
|
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
639 | WebKitDOMHTMLElement *body; |
|
ce92490a3edb
Use insertAdjacentHtml instead of document.write. This seems a lot
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32993
diff
changeset
|
640 | 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
|
641 | 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
|
642 | 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
|
643 | priv->empty = FALSE; |
|
32441
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
644 | } |
|
8a015ca299f9
Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff
changeset
|
645 | |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
646 | void |
|
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
647 | 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
|
648 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
649 | 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
|
650 | priv->vadj = vadj; |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
651 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
652 | |
|
32513
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
653 | void |
|
9352b4c92d13
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32506
diff
changeset
|
654 | 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
|
655 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
656 | 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
|
657 | if (priv->scroll_time) |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
658 | 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
|
659 | if (priv->scroll_src) |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
660 | 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
|
661 | if (smooth) { |
|
32500
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
662 | 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
|
663 | 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
|
664 | } else { |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
665 | priv->scroll_time = NULL; |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
666 | 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
|
667 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
668 | } |
|
d8aa742c6288
webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32489
diff
changeset
|
669 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
670 | void |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
671 | 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
|
672 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
673 | 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
|
674 | GtkAdjustment *vadj = priv->vadj; |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
675 | gdouble scroll_val; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
676 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
677 | #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
|
678 | 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
|
679 | 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
|
680 | #else |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
681 | 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
|
682 | 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
|
683 | #endif |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
684 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
685 | 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
|
686 | } |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
687 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
688 | void |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
689 | 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
|
690 | { |
|
32796
34f384b0d75f
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32794
diff
changeset
|
691 | 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
|
692 | GtkAdjustment *vadj = priv->vadj; |
|
32772
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
693 | gdouble scroll_val; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
694 | gdouble page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
695 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
696 | #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
|
697 | 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
|
698 | 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
|
699 | 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
|
700 | #else |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
701 | page_size = vadj->page_size; |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
702 | 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
|
703 | 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
|
704 | #endif |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
705 | |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
706 | 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
|
707 | } |
|
9d79ccaeedfe
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
708 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
709 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
710 | 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
|
711 | { |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
712 | WebKitDOMDocument *doc; |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
713 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
714 | webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable); |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
715 | |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
716 | doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
717 | if (editable) { |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
718 | webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(doc), |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
719 | "input", G_CALLBACK(editable_input_cb), |
|
33008
b1811b11f907
Fix parameters to input signal handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33007
diff
changeset
|
720 | FALSE, webview); |
|
33007
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
721 | } else { |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
722 | webkit_dom_event_target_remove_event_listener(WEBKIT_DOM_EVENT_TARGET(doc), |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
723 | "input", G_CALLBACK(editable_input_cb), |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
724 | FALSE); |
|
78b670090850
Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33006
diff
changeset
|
725 | } |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
726 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
727 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
728 | 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
|
729 | 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
|
730 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
731 | 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
|
732 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
733 | 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
|
734 | 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
|
735 | 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
|
736 | 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
|
737 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
738 | 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
|
739 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
740 | 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
|
741 | 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
|
742 | 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
|
743 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
744 | 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
|
745 | 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
|
746 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
747 | 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
|
748 | 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
|
749 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
750 | 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
|
751 | |
|
32810
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
752 | 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
|
753 | 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
|
754 | 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
|
755 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
756 | 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
|
757 | 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
|
758 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
759 | 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
|
760 | 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
|
761 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
762 | 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
|
763 | 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
|
764 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
765 | 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
|
766 | 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
|
767 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
768 | 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
|
769 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
770 | 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
|
771 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
772 | /* 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
|
773 | 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
|
774 | 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
|
775 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
776 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
777 | 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
|
778 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
779 | 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
|
780 | &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
|
781 | 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
|
782 | "#%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
|
783 | 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
|
784 | 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
|
785 | 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
|
786 | } else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
787 | 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
|
788 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
789 | 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
|
790 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
791 | 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
|
792 | 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
|
793 | { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
794 | 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
|
795 | &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
|
796 | 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
|
797 | "#%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
|
798 | 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
|
799 | 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
|
800 | 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
|
801 | } else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
802 | 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
|
803 | |
|
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
|
804 | 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
|
805 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
806 | 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
|
807 | 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
|
808 | else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
809 | 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
|
810 | } else { |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
811 | 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
|
812 | 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
|
813 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
814 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
815 | 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
|
816 | 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
|
817 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
818 | 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
|
819 | 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
|
820 | else |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
821 | 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
|
822 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
823 | 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
|
824 | } |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
825 | |
|
17dceb2423c2
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32805
diff
changeset
|
826 | void |
|
33021
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
827 | pidgin_webview_set_spellcheck(GtkWebView *webview, gboolean enable) |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
828 | { |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
829 | WebKitWebSettings *settings; |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
830 | |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
831 | settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webview)); |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
832 | g_object_set(G_OBJECT(settings), "enable-spell-checking", enable, NULL); |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
833 | webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webview), settings); |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
834 | } |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
835 | |
|
3dc4b2cdba7f
Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33020
diff
changeset
|
836 | void |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
837 | 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
|
838 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
839 | 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
|
840 | 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
|
841 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
842 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
843 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
844 | 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
|
845 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
846 | 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
|
847 | 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
|
848 | 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
|
849 | 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
|
850 | 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
|
851 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
852 | |
|
33004
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
853 | gchar * |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
854 | 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
|
855 | { |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
856 | 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
|
857 | 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
|
858 | 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
|
859 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
860 | 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
|
861 | 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
|
862 | 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
|
863 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
864 | 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
|
865 | } |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
866 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
867 | gchar * |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
868 | 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
|
869 | { |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
870 | 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
|
871 | 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
|
872 | 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
|
873 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
874 | 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
|
875 | 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
|
876 | 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
|
877 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
878 | 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
|
879 | } |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
880 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
881 | gchar * |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
882 | 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
|
883 | { |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
884 | 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
|
885 | 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
|
886 | 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
|
887 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
888 | 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
|
889 | 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
|
890 | 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
|
891 | |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
892 | 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
|
893 | } |
|
2a86ad923464
Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32994
diff
changeset
|
894 | |
|
33014
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
895 | gchar * |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
896 | gtk_webview_get_selected_text(GtkWebView *webview) |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
897 | { |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
898 | WebKitDOMDocument *dom; |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
899 | WebKitDOMDOMWindow *win; |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
900 | WebKitDOMDOMSelection *sel; |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
901 | WebKitDOMRange *range; |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
902 | |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
903 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
904 | win = webkit_dom_document_get_default_view(dom); |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
905 | sel = webkit_dom_dom_window_get_selection(win); |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
906 | range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL); |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
907 | |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
908 | return webkit_dom_range_get_text(range); |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
909 | } |
|
2f8a83007ab9
Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33013
diff
changeset
|
910 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
911 | GtkWebViewButtons |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
912 | 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
|
913 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
914 | 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
|
915 | 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
|
916 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
917 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
918 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
919 | 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
|
920 | 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
|
921 | gboolean *strike) |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
922 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
923 | 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
|
924 | 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
|
925 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
926 | 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
|
927 | *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
|
928 | 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
|
929 | *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
|
930 | 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
|
931 | *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
|
932 | 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
|
933 | *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
|
934 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
935 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
936 | char * |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
937 | 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
|
938 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
939 | 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
|
940 | 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
|
941 | 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
|
942 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
943 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
944 | char * |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
945 | 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
|
946 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
947 | 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
|
948 | 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
|
949 | 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
|
950 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
951 | |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
952 | char * |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
953 | 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
|
954 | { |
|
32895
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
955 | 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
|
956 | 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
|
957 | 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
|
958 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
959 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
960 | gint |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
961 | 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
|
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 | 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
|
964 | 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
|
965 | 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
|
966 | |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
967 | 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
|
968 | 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
|
969 | 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
|
970 | 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
|
971 | |
|
fbd3b11e535a
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32894
diff
changeset
|
972 | return size; |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
973 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
974 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
975 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
976 | 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
|
977 | { |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
978 | 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
|
979 | } |
|
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 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
982 | 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
|
983 | { |
|
32813
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
984 | 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
|
985 | |
|
d1dc6f667a34
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32812
diff
changeset
|
986 | 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
|
987 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
988 | 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
|
989 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
990 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
991 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
992 | 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
|
993 | { |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
994 | emit_format_signal(webview, GTK_WEBVIEW_BOLD); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
995 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
996 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
997 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
998 | 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
|
999 | { |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1000 | emit_format_signal(webview, GTK_WEBVIEW_ITALIC); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1001 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1002 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1003 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1004 | 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
|
1005 | { |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1006 | emit_format_signal(webview, GTK_WEBVIEW_UNDERLINE); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1007 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1008 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1009 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1010 | 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
|
1011 | { |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1012 | emit_format_signal(webview, GTK_WEBVIEW_STRIKE); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1013 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1014 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1015 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1016 | 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
|
1017 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
1018 | do_formatting(webview, "foreColor", color); |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1019 | emit_format_signal(webview, GTK_WEBVIEW_FORECOLOR); |
|
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
|
1020 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1021 | return FALSE; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1022 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1023 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1024 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1025 | 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
|
1026 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
1027 | do_formatting(webview, "backColor", color); |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1028 | emit_format_signal(webview, GTK_WEBVIEW_BACKCOLOR); |
|
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
|
1029 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1030 | return FALSE; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1031 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1032 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1033 | gboolean |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1034 | 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
|
1035 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
1036 | do_formatting(webview, "fontName", face); |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1037 | emit_format_signal(webview, GTK_WEBVIEW_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
|
1038 | |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1039 | return FALSE; |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1040 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1041 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1042 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1043 | 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
|
1044 | { |
|
33006
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
1045 | char *tmp = g_strdup_printf("%d", size); |
|
86765d2f6f3b
Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33004
diff
changeset
|
1046 | do_formatting(webview, "fontSize", tmp); |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1047 | emit_format_signal(webview, GTK_WEBVIEW_SHRINK|GTK_WEBVIEW_GROW); |
|
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
|
1048 | 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
|
1049 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1050 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1051 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1052 | 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
|
1053 | { |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1054 | emit_format_signal(webview, GTK_WEBVIEW_SHRINK); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1055 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1056 | |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1057 | void |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1058 | 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
|
1059 | { |
|
33018
cfa94708af72
Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33017
diff
changeset
|
1060 | emit_format_signal(webview, GTK_WEBVIEW_GROW); |
|
32805
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1061 | } |
|
57f914c32dc4
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32803
diff
changeset
|
1062 | |
|
33012
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1063 | void |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1064 | gtk_webview_insert_hr(GtkWebView *webview) |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1065 | { |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1066 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1067 | WebKitDOMDocument *dom; |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1068 | |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1069 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1070 | |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1071 | priv->edit.block_changed = TRUE; |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1072 | webkit_dom_document_exec_command(dom, "insertHorizontalRule", FALSE, ""); |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1073 | priv->edit.block_changed = FALSE; |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1074 | } |
|
3a742f00a0f4
Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33010
diff
changeset
|
1075 | |
|
33013
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1076 | void |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1077 | gtk_webview_insert_link(GtkWebView *webview, const char *url, const char *desc) |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1078 | { |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1079 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1080 | WebKitDOMDocument *dom; |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1081 | char *link; |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1082 | |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1083 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
33016
509c717fcf6e
The URL probably needs to be quoted.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33014
diff
changeset
|
1084 | link = g_strdup_printf("<a href='%s'>%s</a>", url, desc ? desc : url); |
|
33013
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1085 | |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1086 | priv->edit.block_changed = TRUE; |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1087 | webkit_dom_document_exec_command(dom, "insertHTML", FALSE, link); |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1088 | priv->edit.block_changed = FALSE; |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1089 | g_free(link); |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1090 | } |
|
f62232fb738a
Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33012
diff
changeset
|
1091 | |
|
33017
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1092 | void |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1093 | gtk_webview_insert_image(GtkWebView *webview, int id) |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1094 | { |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1095 | GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1096 | WebKitDOMDocument *dom; |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1097 | char *img; |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1098 | |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1099 | dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1100 | img = g_strdup_printf("<img src='%s'/>", get_image_src_from_id(priv, id)); |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1101 | |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1102 | priv->edit.block_changed = TRUE; |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1103 | webkit_dom_document_exec_command(dom, "insertHTML", FALSE, img); |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1104 | priv->edit.block_changed = FALSE; |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1105 | g_free(img); |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1106 | } |
|
d21ab88ad911
Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33016
diff
changeset
|
1107 |