Mercurial > pidgin
annotate pidgin/gtkwebview.c @ 32562:4547ab591cfc
WebKit knows the current formatting of the selection better than we
do, so don't bother saving it ourselves.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 27 Feb 2012 06:35:27 +0000 |
parents | be0162cb27c4 |
children | e63ca20258fb |
rev | line source |
---|---|
32065 | 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 | |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
32065 | 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 | |
32437
5dea9a26078d
Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32421
diff
changeset
|
28 #include "internal.h" |
5dea9a26078d
Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32421
diff
changeset
|
29 #include "pidgin.h" |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
30 |
32456
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
31 #include <gdk/gdkkeysyms.h> |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
32 #include "gtkwebview.h" |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
33 |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
34 #define MAX_FONT_SIZE 7 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
35 #define MAX_SCROLL_TIME 0.4 /* seconds */ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
36 #define SCROLL_DELAY 33 /* milliseconds */ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
37 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
38 #define GTK_WEBVIEW_GET_PRIVATE(obj) \ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
39 (G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_WEBVIEW, GtkWebViewPriv)) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
40 |
32456
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
41 enum { |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
42 BUTTONS_UPDATE, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
43 TOGGLE_FORMAT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
44 CLEAR_FORMAT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
45 UPDATE_FORMAT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
46 LAST_SIGNAL |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
47 }; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
48 static guint signals[LAST_SIGNAL] = { 0 }; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
49 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
50 /****************************************************************************** |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
51 * Structs |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
52 *****************************************************************************/ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
53 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
54 typedef struct _GtkWebViewPriv { |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
55 GHashTable *images; /**< a map from id to temporary file for the image */ |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
56 gboolean empty; /**< whether anything has been appended **/ |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
57 |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
58 /* JS execute queue */ |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
59 GQueue *js_queue; |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
60 gboolean is_loading; |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
61 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
62 /* Scroll adjustments */ |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
63 GtkAdjustment *vadj; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
64 guint scroll_src; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
65 GTimer *scroll_time; |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
66 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
67 /* Format options */ |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
68 GtkWebViewButtons format_functions; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
69 struct { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
70 gboolean wbfo:1; /* Whole buffer formatting only. */ |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
71 gchar *background; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
72 } edit; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
73 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
74 } GtkWebViewPriv; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
75 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
76 /****************************************************************************** |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
77 * Globals |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
78 *****************************************************************************/ |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
79 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
80 static WebKitWebViewClass *parent_class = NULL; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
81 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
82 /****************************************************************************** |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
83 * Helpers |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
84 *****************************************************************************/ |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
85 |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
86 static const char * |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
87 get_image_src_from_id(GtkWebViewPriv *priv, int id) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
88 { |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
89 char *src; |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
90 PurpleStoredImage *img; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
91 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
92 if (priv->images) { |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
93 /* Check for already loaded image */ |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
94 src = (char *)g_hash_table_lookup(priv->images, GINT_TO_POINTER(id)); |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
95 if (src) |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
96 return src; |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
97 } else { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
98 priv->images = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
99 NULL, g_free); |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
100 } |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
101 |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
102 /* Find image in store */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
103 img = purple_imgstore_find_by_id(id); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
104 |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
105 src = (char *)purple_imgstore_get_filename(img); |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
106 if (src) { |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
107 src = g_strdup_printf("file://%s", src); |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
108 } else { |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
109 char *tmp; |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
110 tmp = purple_base64_encode(purple_imgstore_get_data(img), |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
111 purple_imgstore_get_size(img)); |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
112 src = g_strdup_printf("data:base64,%s", tmp); |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
113 g_free(tmp); |
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
114 } |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
115 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
116 g_hash_table_insert(priv->images, GINT_TO_POINTER(id), src); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
117 |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
118 return src; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
119 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
120 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
121 /* |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
122 * Replace all <img id=""> tags with <img src="">. I hoped to never |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
123 * write any HTML parsing code, but I'm forced to do this, until |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
124 * purple changes the way it works. |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
125 */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
126 static char * |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
127 replace_img_id_with_src(GtkWebViewPriv *priv, const char *html) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
128 { |
32440
1809d65d4f92
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32439
diff
changeset
|
129 GString *buffer = g_string_new(NULL); |
1809d65d4f92
This strlen seems redundant.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32439
diff
changeset
|
130 const char *cur = html; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
131 char *id; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
132 int nid; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
133 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
134 while (*cur) { |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
135 const char *img = strstr(cur, "<img"); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
136 if (!img) { |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
137 g_string_append(buffer, cur); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
138 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
139 } else |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
140 g_string_append_len(buffer, cur, img - cur); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
141 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
142 cur = strstr(img, "/>"); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
143 if (!cur) |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
144 cur = strstr(img, ">"); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
145 |
32066 | 146 if (!cur) { /* invalid html? */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
147 g_string_printf(buffer, "%s", html); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
148 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
149 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
150 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
151 if (strstr(img, "src=") || !strstr(img, "id=")) { |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
152 g_string_printf(buffer, "%s", html); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
153 break; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
154 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
155 |
32066 | 156 /* |
157 * if this is valid HTML, then I can be sure that it | |
158 * has an id= and does not have an src=, since | |
159 * '=' cannot appear in parameters. | |
160 */ | |
161 | |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
162 id = strstr(img, "id=") + 3; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
163 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
164 /* *id can't be \0, since a ">" appears after this */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
165 if (isdigit(*id)) |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
166 nid = atoi(id); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
167 else |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
168 nid = atoi(id + 1); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
169 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
170 /* let's dump this, tag and then dump the src information */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
171 g_string_append_len(buffer, img, cur - img); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
172 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
173 g_string_append_printf(buffer, " src='%s' ", get_image_src_from_id(priv, nid)); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
174 } |
32066 | 175 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
176 return g_string_free(buffer, FALSE); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
177 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
178 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
179 static gboolean |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
180 process_js_script_queue(GtkWebView *webview) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
181 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
182 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
183 char *script; |
32081
3bd8fb942ea4
Yep, tested, and changed some code from previous commit. This is a hard
tdrhq@soc.pidgin.im
parents:
32080
diff
changeset
|
184 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
185 if (priv->is_loading) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
186 return FALSE; /* we will be called when loaded */ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
187 if (!priv->js_queue || g_queue_is_empty(priv->js_queue)) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
188 return FALSE; /* nothing to do! */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
189 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
190 script = g_queue_pop_head(priv->js_queue); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
191 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
192 g_free(script); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
193 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
194 return TRUE; /* there may be more for now */ |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
195 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
196 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
197 static void |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
198 webview_load_started(WebKitWebView *webview, WebKitWebFrame *frame, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
199 gpointer userdata) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
200 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
201 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
202 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
203 /* is there a better way to test for is_loading? */ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
204 priv->is_loading = TRUE; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
205 } |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
206 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
207 static void |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
208 webview_load_finished(WebKitWebView *webview, WebKitWebFrame *frame, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
209 gpointer userdata) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
210 { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
211 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
212 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
213 priv->is_loading = FALSE; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
214 g_idle_add((GSourceFunc)process_js_script_queue, webview); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
215 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
216 |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
217 static gboolean |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
218 webview_link_clicked(WebKitWebView *webview, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
219 WebKitWebFrame *frame, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
220 WebKitNetworkRequest *request, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
221 WebKitWebNavigationAction *navigation_action, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
222 WebKitWebPolicyDecision *policy_decision, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
223 gpointer userdata) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
224 { |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
225 const gchar *uri; |
32126
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32122
diff
changeset
|
226 WebKitWebNavigationReason reason; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
227 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
228 uri = webkit_network_request_get_uri(request); |
32126
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32122
diff
changeset
|
229 reason = webkit_web_navigation_action_get_reason(navigation_action); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
230 |
32126
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32122
diff
changeset
|
231 if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32122
diff
changeset
|
232 /* the gtk imhtml way was to create an idle cb, not sure |
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32122
diff
changeset
|
233 * why, so right now just using purple_notify_uri directly */ |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
234 purple_notify_uri(NULL, uri); |
32446
aeaf9eebd5ec
If we handle a navigation request, then we should tell WebKit
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32445
diff
changeset
|
235 webkit_web_policy_decision_ignore(policy_decision); |
32449
692d5408983d
We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32446
diff
changeset
|
236 } else if (reason == WEBKIT_WEB_NAVIGATION_REASON_OTHER) |
32143
e7eba7a6a989
Let webview manage the navigation ONLY if the reason is the user clicked a link.
masca@cpw.pidgin.im
parents:
32133
diff
changeset
|
237 webkit_web_policy_decision_use(policy_decision); |
32449
692d5408983d
We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32446
diff
changeset
|
238 else |
692d5408983d
We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32446
diff
changeset
|
239 webkit_web_policy_decision_ignore(policy_decision); |
32126
a17de1f525a9
Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
masca@cpw.pidgin.im
parents:
32122
diff
changeset
|
240 |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
241 return TRUE; |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
242 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
243 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
244 /* |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
245 * Smoothly scroll a WebView. |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
246 * |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
247 * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
248 */ |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
249 static gboolean |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
250 smooth_scroll_cb(gpointer data) |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
251 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
252 GtkWebViewPriv *priv = data; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
253 GtkAdjustment *adj; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
254 gdouble max_val; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
255 gdouble scroll_val; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
256 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
257 g_return_val_if_fail(priv->scroll_time != NULL, FALSE); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
258 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
259 adj = priv->vadj; |
32443
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
260 #if GTK_CHECK_VERSION(2,14,0) |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
261 max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
262 #else |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
263 max_val = adj->upper - adj->page_size; |
32443
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
264 #endif |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
265 scroll_val = gtk_adjustment_get_value(adj) + |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
266 ((max_val - gtk_adjustment_get_value(adj)) / 3); |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
267 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
268 if (g_timer_elapsed(priv->scroll_time, NULL) > MAX_SCROLL_TIME |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
269 || scroll_val >= max_val) { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
270 /* time's up. jump to the end and kill the timer */ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
271 gtk_adjustment_set_value(adj, max_val); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
272 g_timer_destroy(priv->scroll_time); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
273 priv->scroll_time = NULL; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
274 g_source_remove(priv->scroll_src); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
275 priv->scroll_src = 0; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
276 return FALSE; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
277 } |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
278 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
279 /* scroll by 1/3rd the remaining distance */ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
280 gtk_adjustment_set_value(adj, scroll_val); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
281 return TRUE; |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
282 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
283 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
284 static gboolean |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
285 scroll_idle_cb(gpointer data) |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
286 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
287 GtkWebViewPriv *priv = data; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
288 GtkAdjustment *adj = priv->vadj; |
32443
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
289 gdouble max_val; |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
290 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
291 if (adj) { |
32443
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
292 #if GTK_CHECK_VERSION(2,14,0) |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
293 max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
294 #else |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
295 max_val = adj->upper - adj->page_size; |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
296 #endif |
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
297 gtk_adjustment_set_value(adj, max_val); |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
298 } |
32443
16925948a003
Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32442
diff
changeset
|
299 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
300 priv->scroll_src = 0; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
301 return FALSE; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
302 } |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
303 |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
304 static void |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
305 webview_clear_formatting(GtkWebView *webview) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
306 { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
307 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32561
be0162cb27c4
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32539
diff
changeset
|
308 WebKitDOMDocument *dom; |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
309 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
310 if (!webkit_web_view_get_editable(WEBKIT_WEB_VIEW(webview))) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
311 return; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
312 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
313 g_free(priv->edit.background); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
314 priv->edit.background = NULL; |
32561
be0162cb27c4
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32539
diff
changeset
|
315 |
be0162cb27c4
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32539
diff
changeset
|
316 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
be0162cb27c4
Implement webview formatting clearing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32539
diff
changeset
|
317 webkit_dom_document_exec_command(dom, "removeFormat", FALSE, ""); |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
318 } |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
319 |
32456
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
320 static void |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
321 webview_toggle_format(GtkWebView *webview, GtkWebViewButtons buttons) |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
322 { |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
323 /* since this function is the handler for the formatting keystrokes, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
324 we need to check here that the formatting attempted is permitted */ |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
325 buttons &= gtk_webview_get_format_functions(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
326 |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
327 switch (buttons) { |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
328 case GTK_WEBVIEW_BOLD: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
329 gtk_webview_toggle_bold(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
330 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
331 case GTK_WEBVIEW_ITALIC: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
332 gtk_webview_toggle_italic(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
333 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
334 case GTK_WEBVIEW_UNDERLINE: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
335 gtk_webview_toggle_underline(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
336 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
337 case GTK_WEBVIEW_STRIKE: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
338 gtk_webview_toggle_strike(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
339 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
340 case GTK_WEBVIEW_SHRINK: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
341 gtk_webview_font_shrink(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
342 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
343 case GTK_WEBVIEW_GROW: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
344 gtk_webview_font_grow(webview); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
345 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
346 default: |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
347 break; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
348 } |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
349 } |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
350 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
351 /****************************************************************************** |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
352 * GObject Stuff |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
353 *****************************************************************************/ |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
354 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
355 GtkWidget * |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
356 gtk_webview_new(void) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
357 { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
358 return GTK_WIDGET(g_object_new(gtk_webview_get_type(), NULL)); |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
359 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
360 |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
361 static void |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
362 gtk_webview_finalize(GObject *webview) |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
363 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
364 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
365 gpointer temp; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
366 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
367 while ((temp = g_queue_pop_head(priv->js_queue))) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
368 g_free(temp); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
369 g_queue_free(priv->js_queue); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
370 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
371 if (priv->images) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
372 g_hash_table_unref(priv->images); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
373 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
374 G_OBJECT_CLASS(parent_class)->finalize(G_OBJECT(webview)); |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
375 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
376 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
377 static void |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
378 gtk_webview_class_init(GtkWebViewClass *klass, gpointer userdata) |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
379 { |
32456
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
380 GObjectClass *gobject_class; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
381 GtkBindingSet *binding_set; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
382 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
383 parent_class = g_type_class_ref(webkit_web_view_get_type()); |
32456
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
384 gobject_class = G_OBJECT_CLASS(klass); |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
385 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
386 g_type_class_add_private(klass, sizeof(GtkWebViewPriv)); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
387 |
32456
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
388 signals[BUTTONS_UPDATE] = g_signal_new("allowed-formats-updated", |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
389 G_TYPE_FROM_CLASS(gobject_class), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
390 G_SIGNAL_RUN_FIRST, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
391 G_STRUCT_OFFSET(GtkWebViewClass, buttons_update), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
392 NULL, 0, g_cclosure_marshal_VOID__INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
393 G_TYPE_NONE, 1, G_TYPE_INT); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
394 signals[TOGGLE_FORMAT] = g_signal_new("format-toggled", |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
395 G_TYPE_FROM_CLASS(gobject_class), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
396 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
397 G_STRUCT_OFFSET(GtkWebViewClass, toggle_format), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
398 NULL, 0, g_cclosure_marshal_VOID__INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
399 G_TYPE_NONE, 1, G_TYPE_INT); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
400 signals[CLEAR_FORMAT] = g_signal_new("format-cleared", |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
401 G_TYPE_FROM_CLASS(gobject_class), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
402 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
403 G_STRUCT_OFFSET(GtkWebViewClass, clear_format), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
404 NULL, 0, g_cclosure_marshal_VOID__VOID, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
405 G_TYPE_NONE, 0); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
406 signals[UPDATE_FORMAT] = g_signal_new("format-updated", |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
407 G_TYPE_FROM_CLASS(gobject_class), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
408 G_SIGNAL_RUN_FIRST, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
409 G_STRUCT_OFFSET(GtkWebViewClass, update_format), |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
410 NULL, 0, g_cclosure_marshal_VOID__VOID, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
411 G_TYPE_NONE, 0); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
412 |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
413 klass->toggle_format = webview_toggle_format; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
414 klass->clear_format = webview_clear_formatting; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
415 |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
416 gobject_class->finalize = gtk_webview_finalize; |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
417 |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
418 binding_set = gtk_binding_set_by_class(parent_class); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
419 gtk_binding_entry_add_signal(binding_set, GDK_KEY_b, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
420 "format-toggled", 1, G_TYPE_INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
421 GTK_WEBVIEW_BOLD); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
422 gtk_binding_entry_add_signal(binding_set, GDK_KEY_i, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
423 "format-toggled", 1, G_TYPE_INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
424 GTK_WEBVIEW_ITALIC); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
425 gtk_binding_entry_add_signal(binding_set, GDK_KEY_u, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
426 "format-toggled", 1, G_TYPE_INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
427 GTK_WEBVIEW_UNDERLINE); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
428 gtk_binding_entry_add_signal(binding_set, GDK_KEY_plus, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
429 "format-toggled", 1, G_TYPE_INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
430 GTK_WEBVIEW_GROW); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
431 gtk_binding_entry_add_signal(binding_set, GDK_KEY_equal, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
432 "format-toggled", 1, G_TYPE_INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
433 GTK_WEBVIEW_GROW); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
434 gtk_binding_entry_add_signal(binding_set, GDK_KEY_minus, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
435 "format-toggled", 1, G_TYPE_INT, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
436 GTK_WEBVIEW_SHRINK); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
437 |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
438 binding_set = gtk_binding_set_by_class(klass); |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
439 gtk_binding_entry_add_signal(binding_set, GDK_KEY_r, GDK_CONTROL_MASK, |
0250c8b3e159
Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32455
diff
changeset
|
440 "format-cleared", 0); |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
441 } |
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
442 |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
443 static void |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
444 gtk_webview_init(GtkWebView *webview, gpointer userdata) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
445 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
446 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
447 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
448 priv->empty = TRUE; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
449 priv->js_queue = g_queue_new(); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
450 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
451 g_signal_connect(webview, "navigation-policy-decision-requested", |
32445
072e2329b659
Passing the webview as userdata when the webview is the object
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32443
diff
changeset
|
452 G_CALLBACK(webview_link_clicked), NULL); |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
453 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
454 g_signal_connect(webview, "load-started", |
32445
072e2329b659
Passing the webview as userdata when the webview is the object
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32443
diff
changeset
|
455 G_CALLBACK(webview_load_started), NULL); |
32080
b89351c7580b
safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
tdrhq@soc.pidgin.im
parents:
32066
diff
changeset
|
456 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
457 g_signal_connect(webview, "load-finished", |
32445
072e2329b659
Passing the webview as userdata when the webview is the object
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32443
diff
changeset
|
458 G_CALLBACK(webview_load_finished), NULL); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
459 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
460 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
461 GType |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
462 gtk_webview_get_type(void) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
463 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
464 static GType mview_type = 0; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
465 if (G_UNLIKELY(mview_type == 0)) { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
466 static const GTypeInfo mview_info = { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
467 sizeof(GtkWebViewClass), |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
468 NULL, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
469 NULL, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
470 (GClassInitFunc)gtk_webview_class_init, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
471 NULL, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
472 NULL, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
473 sizeof(GtkWebView), |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
474 0, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
475 (GInstanceInitFunc)gtk_webview_init, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
476 NULL |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
477 }; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
478 mview_type = g_type_register_static(webkit_web_view_get_type(), |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
479 "GtkWebView", &mview_info, 0); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
480 } |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
481 return mview_type; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
482 } |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
483 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
484 /***************************************************************************** |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
485 * Public API functions |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
486 *****************************************************************************/ |
32439
5022cf604d6e
Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32437
diff
changeset
|
487 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
488 gboolean |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
489 gtk_webview_is_empty(GtkWebView *webview) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
490 { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
491 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
492 return priv->empty; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
493 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
494 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
495 char * |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
496 gtk_webview_quote_js_string(const char *text) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
497 { |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
498 GString *str = g_string_new("\""); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
499 const char *cur = text; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
500 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
501 while (cur && *cur) { |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
502 switch (*cur) { |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
503 case '\\': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
504 g_string_append(str, "\\\\"); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
505 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
506 case '\"': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
507 g_string_append(str, "\\\""); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
508 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
509 case '\r': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
510 g_string_append(str, "<br/>"); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
511 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
512 case '\n': |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
513 break; |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
514 default: |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
515 g_string_append_c(str, *cur); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
516 } |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
517 cur++; |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
518 } |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
519 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
520 g_string_append_c(str, '"'); |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
521 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
522 return g_string_free(str, FALSE); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
523 } |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
524 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
525 void |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
526 gtk_webview_safe_execute_script(GtkWebView *webview, const char *script) |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
527 { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
528 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
529 g_queue_push_tail(priv->js_queue, g_strdup(script)); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
530 g_idle_add((GSourceFunc)process_js_script_queue, webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
531 } |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
532 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
533 void |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
534 gtk_webview_load_html_string_with_imgstore(GtkWebView *webview, const char *html) |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
535 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
536 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
537 char *html_imged; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
538 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
539 if (priv->images) { |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
540 g_hash_table_unref(priv->images); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
541 priv->images = NULL; |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
542 } |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
543 |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
544 html_imged = replace_img_id_with_src(priv, html); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
545 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), html_imged, NULL, |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
546 NULL, "file:///"); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
547 g_free(html_imged); |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
548 } |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
549 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
550 /* this is a "hack", my plan is to eventually handle this |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
551 * correctly using a signals and a plugin: the plugin will have |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
552 * the information as to what javascript function to call. It seems |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
553 * wrong to hardcode that here. |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
554 */ |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
555 void |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
556 gtk_webview_append_html(GtkWebView *webview, const char *html) |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
557 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
558 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
559 char *escaped = gtk_webview_quote_js_string(html); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
560 char *script = g_strdup_printf("document.write(%s)", escaped); |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
561 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
562 priv->empty = FALSE; |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
563 g_free(script); |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
564 g_free(escaped); |
32061
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
565 } |
ac42a0dfda48
Apparently I missed these in my previous commit.
tdrhq@soc.pidgin.im
parents:
diff
changeset
|
566 |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
567 void |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
568 gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj) |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
569 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
570 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
571 priv->vadj = vadj; |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
572 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
573 |
32133
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
574 void |
8e1ec44ede75
Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32126
diff
changeset
|
575 gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth) |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
576 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
577 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
578 if (priv->scroll_time) |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
579 g_timer_destroy(priv->scroll_time); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
580 if (priv->scroll_src) |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
581 g_source_remove(priv->scroll_src); |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
582 if (smooth) { |
32120
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
583 priv->scroll_time = g_timer_new(); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
584 priv->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, priv, NULL); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
585 } else { |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
586 priv->scroll_time = NULL; |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
587 priv->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, priv, NULL); |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
588 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
589 } |
24c8a98a6acc
webkit: Scroll to end when appending html.
masca@cpw.pidgin.im
parents:
32109
diff
changeset
|
590 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
591 void |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
592 gtk_webview_page_up(GtkWebView *webview) |
32419
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
593 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
594 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
595 GtkAdjustment *vadj = priv->vadj; |
32419
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
596 gdouble scroll_val; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
597 |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
598 #if GTK_CHECK_VERSION(2,14,0) |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
599 scroll_val = gtk_adjustment_get_value(vadj) - gtk_adjustment_get_page_size(vadj); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
600 scroll_val = MAX(scroll_val, gtk_adjustment_get_lower(vadj)); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
601 #else |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
602 scroll_val = gtk_adjustment_get_value(vadj) - vadj->page_size; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
603 scroll_val = MAX(scroll_val, vadj->lower); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
604 #endif |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
605 |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
606 gtk_adjustment_set_value(vadj, scroll_val); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
607 } |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
608 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
609 void |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
610 gtk_webview_page_down(GtkWebView *webview) |
32419
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
611 { |
32442
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
612 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
fb8447f6649c
Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32440
diff
changeset
|
613 GtkAdjustment *vadj = priv->vadj; |
32419
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
614 gdouble scroll_val; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
615 gdouble page_size; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
616 |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
617 #if GTK_CHECK_VERSION(2,14,0) |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
618 page_size = gtk_adjustment_get_page_size(vadj); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
619 scroll_val = gtk_adjustment_get_value(vadj) + page_size; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
620 scroll_val = MIN(scroll_val, gtk_adjustment_get_upper(vadj) - page_size); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
621 #else |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
622 page_size = vadj->page_size; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
623 scroll_val = gtk_adjustment_get_value(vadj) + page_size; |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
624 scroll_val = MIN(scroll_val, vadj->upper - page_size); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
625 #endif |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
626 |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
627 gtk_adjustment_set_value(vadj, scroll_val); |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
628 } |
7b9566b77501
Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32199
diff
changeset
|
629 |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
630 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
631 gtk_webview_set_editable(GtkWebView *webview, gboolean editable) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
632 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
633 webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
634 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
635 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
636 void |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
637 gtk_webview_setup_entry(GtkWebView *webview, PurpleConnectionFlags flags) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
638 { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
639 GtkWebViewButtons buttons; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
640 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
641 if (flags & PURPLE_CONNECTION_HTML) { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
642 char color[8]; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
643 GdkColor fg_color, bg_color; |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
644 gboolean bold, italic, underline, strike; |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
645 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
646 buttons = GTK_WEBVIEW_ALL; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
647 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
648 if (flags & PURPLE_CONNECTION_NO_BGCOLOR) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
649 buttons &= ~GTK_WEBVIEW_BACKCOLOR; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
650 if (flags & PURPLE_CONNECTION_NO_FONTSIZE) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
651 { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
652 buttons &= ~GTK_WEBVIEW_GROW; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
653 buttons &= ~GTK_WEBVIEW_SHRINK; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
654 } |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
655 if (flags & PURPLE_CONNECTION_NO_URLDESC) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
656 buttons &= ~GTK_WEBVIEW_LINKDESC; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
657 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
658 gtk_webview_get_current_format(webview, &bold, &italic, &underline, &strike); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
659 |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
660 gtk_webview_set_format_functions(webview, GTK_WEBVIEW_ALL); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
661 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != bold) |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
662 gtk_webview_toggle_bold(webview); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
663 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
664 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != italic) |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
665 gtk_webview_toggle_italic(webview); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
666 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
667 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != underline) |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
668 gtk_webview_toggle_underline(webview); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
669 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
670 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike") != strike) |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
671 gtk_webview_toggle_strike(webview); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
672 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
673 gtk_webview_toggle_fontface(webview, |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
674 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face")); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
675 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
676 if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE)) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
677 { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
678 int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size"); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
679 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
680 /* 3 is the default. */ |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
681 if (size != 3) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
682 gtk_webview_font_set_size(webview, size); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
683 } |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
684 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
685 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
686 { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
687 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
688 &fg_color); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
689 g_snprintf(color, sizeof(color), |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
690 "#%02x%02x%02x", |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
691 fg_color.red / 256, |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
692 fg_color.green / 256, |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
693 fg_color.blue / 256); |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
694 } else |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
695 strcpy(color, ""); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
696 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
697 gtk_webview_toggle_forecolor(webview, color); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
698 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
699 if (!(flags & PURPLE_CONNECTION_NO_BGCOLOR) && |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
700 strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0) |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
701 { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
702 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
703 &bg_color); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
704 g_snprintf(color, sizeof(color), |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
705 "#%02x%02x%02x", |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
706 bg_color.red / 256, |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
707 bg_color.green / 256, |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
708 bg_color.blue / 256); |
32455
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
709 } else |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
710 strcpy(color, ""); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
711 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
712 gtk_webview_toggle_background(webview, color); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
713 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
714 if (flags & PURPLE_CONNECTION_FORMATTING_WBFO) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
715 gtk_webview_set_whole_buffer_formatting_only(webview, TRUE); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
716 else |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
717 gtk_webview_set_whole_buffer_formatting_only(webview, FALSE); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
718 } else { |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
719 buttons = GTK_WEBVIEW_SMILEY | GTK_WEBVIEW_IMAGE; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
720 webview_clear_formatting(webview); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
721 } |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
722 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
723 if (flags & PURPLE_CONNECTION_NO_IMAGES) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
724 buttons &= ~GTK_WEBVIEW_IMAGE; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
725 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
726 if (flags & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
727 buttons |= GTK_WEBVIEW_CUSTOM_SMILEY; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
728 else |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
729 buttons &= ~GTK_WEBVIEW_CUSTOM_SMILEY; |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
730 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
731 gtk_webview_set_format_functions(webview, buttons); |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
732 } |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
733 |
c5e5938bb89a
Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32450
diff
changeset
|
734 void |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
735 gtk_webview_set_whole_buffer_formatting_only(GtkWebView *webview, gboolean wbfo) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
736 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
737 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
738 priv->edit.wbfo = wbfo; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
739 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
740 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
741 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
742 gtk_webview_set_format_functions(GtkWebView *webview, GtkWebViewButtons buttons) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
743 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
744 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32457
d503827d7fcc
Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32456
diff
changeset
|
745 GObject *object = g_object_ref(G_OBJECT(webview)); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
746 priv->format_functions = buttons; |
32457
d503827d7fcc
Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32456
diff
changeset
|
747 g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
d503827d7fcc
Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32456
diff
changeset
|
748 g_object_unref(object); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
749 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
750 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
751 GtkWebViewButtons |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
752 gtk_webview_get_format_functions(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
753 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
754 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
755 return priv->format_functions; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
756 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
757 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
758 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
759 gtk_webview_get_current_format(GtkWebView *webview, gboolean *bold, |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
760 gboolean *italic, gboolean *underline, |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
761 gboolean *strike) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
762 { |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
763 WebKitDOMDocument *dom; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
764 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
765 |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
766 if (bold) |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
767 *bold = webkit_dom_document_query_command_state(dom, "bold"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
768 if (italic) |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
769 *italic = webkit_dom_document_query_command_state(dom, "italic"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
770 if (underline) |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
771 *underline = webkit_dom_document_query_command_state(dom, "underline"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
772 if (strike) |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
773 *strike = webkit_dom_document_query_command_state(dom, "strikethrough"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
774 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
775 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
776 char * |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
777 gtk_webview_get_current_fontface(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
778 { |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
779 WebKitDOMDocument *dom; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
780 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
781 return webkit_dom_document_query_command_value(dom, "fontName"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
782 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
783 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
784 char * |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
785 gtk_webview_get_current_forecolor(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
786 { |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
787 WebKitDOMDocument *dom; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
788 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
789 return webkit_dom_document_query_command_value(dom, "foreColor"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
790 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
791 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
792 char * |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
793 gtk_webview_get_current_backcolor(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
794 { |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
795 WebKitDOMDocument *dom; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
796 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
797 return webkit_dom_document_query_command_value(dom, "backColor"); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
798 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
799 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
800 char * |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
801 gtk_webview_get_current_background(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
802 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
803 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
804 return g_strdup(priv->edit.background); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
805 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
806 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
807 gint |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
808 gtk_webview_get_current_fontsize(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
809 { |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
810 WebKitDOMDocument *dom; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
811 gchar *text; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
812 gint size; |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
813 |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
814 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
815 text = webkit_dom_document_query_command_value(dom, "fontSize"); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
816 size = atoi(text); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
817 g_free(text); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
818 |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
819 return size; |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
820 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
821 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
822 gboolean |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
823 gtk_webview_get_editable(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
824 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
825 return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(webview)); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
826 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
827 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
828 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
829 gtk_webview_clear_formatting(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
830 { |
32458
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
831 GObject *object; |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
832 |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
833 object = g_object_ref(G_OBJECT(webview)); |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
834 g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
835 |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
836 gtk_widget_grab_focus(GTK_WIDGET(webview)); |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
837 |
c89d7ad82dba
Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32457
diff
changeset
|
838 g_object_unref(object); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
839 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
840 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
841 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
842 gtk_webview_toggle_bold(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
843 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
844 WebKitDOMDocument *dom; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
845 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
846 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
847 webkit_dom_document_exec_command(dom, "bold", FALSE, ""); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
848 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
849 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
850 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
851 gtk_webview_toggle_italic(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
852 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
853 WebKitDOMDocument *dom; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
854 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
855 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
856 webkit_dom_document_exec_command(dom, "italic", FALSE, ""); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
857 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
858 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
859 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
860 gtk_webview_toggle_underline(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
861 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
862 WebKitDOMDocument *dom; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
863 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
864 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
865 webkit_dom_document_exec_command(dom, "underline", FALSE, ""); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
866 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
867 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
868 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
869 gtk_webview_toggle_strike(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
870 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
871 WebKitDOMDocument *dom; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
872 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
873 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
874 webkit_dom_document_exec_command(dom, "strikethrough", FALSE, ""); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
875 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
876 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
877 gboolean |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
878 gtk_webview_toggle_forecolor(GtkWebView *webview, const char *color) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
879 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
880 WebKitDOMDocument *dom; |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
881 |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
882 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
883 webkit_dom_document_exec_command(dom, "foreColor", FALSE, color); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
884 |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
885 return FALSE; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
886 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
887 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
888 gboolean |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
889 gtk_webview_toggle_backcolor(GtkWebView *webview, const char *color) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
890 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
891 WebKitDOMDocument *dom; |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
892 |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
893 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
894 webkit_dom_document_exec_command(dom, "backColor", FALSE, color); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
895 |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
896 return FALSE; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
897 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
898 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
899 gboolean |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
900 gtk_webview_toggle_background(GtkWebView *webview, const char *color) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
901 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
902 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
903 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
904 g_free(priv->edit.background); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
905 priv->edit.background = g_strdup(color); |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
906 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
907 return FALSE; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
908 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
909 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
910 gboolean |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
911 gtk_webview_toggle_fontface(GtkWebView *webview, const char *face) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
912 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
913 WebKitDOMDocument *dom; |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
914 |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
915 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
916 webkit_dom_document_exec_command(dom, "fontName", FALSE, face); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
917 |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
918 return FALSE; |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
919 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
920 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
921 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
922 gtk_webview_font_set_size(GtkWebView *webview, gint size) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
923 { |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
924 WebKitDOMDocument *dom; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
925 char *tmp; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
926 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
927 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
928 tmp = g_strdup_printf("%d", size); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
929 webkit_dom_document_exec_command(dom, "fontSize", FALSE, tmp); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
930 g_free(tmp); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
931 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
932 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
933 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
934 gtk_webview_font_shrink(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
935 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
936 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
937 WebKitDOMDocument *dom; |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
938 gint fontsize; |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
939 char *tmp; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
940 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
941 fontsize = gtk_webview_get_current_fontsize(webview); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
942 fontsize = MAX(fontsize - 1, 1); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
943 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
944 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
945 tmp = g_strdup_printf("%d", fontsize); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
946 webkit_dom_document_exec_command(dom, "fontSize", FALSE, tmp); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
947 g_free(tmp); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
948 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
949 |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
950 void |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
951 gtk_webview_font_grow(GtkWebView *webview) |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
952 { |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
953 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
954 WebKitDOMDocument *dom; |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
955 gint fontsize; |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
956 char *tmp; |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
957 |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
958 fontsize = gtk_webview_get_current_fontsize(webview); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
959 fontsize = MIN(fontsize + 1, MAX_FONT_SIZE); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
960 |
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
961 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview)); |
32562
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
962 tmp = g_strdup_printf("%d", fontsize); |
4547ab591cfc
WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32561
diff
changeset
|
963 webkit_dom_document_exec_command(dom, "fontSize", FALSE, tmp); |
32468
1874e96cf513
Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32458
diff
changeset
|
964 g_free(tmp); |
32450
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
965 } |
0d50155445fd
Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32449
diff
changeset
|
966 |