pidgin/gtkwebview.c

Fri, 04 Apr 2014 23:13:29 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Fri, 04 Apr 2014 23:13:29 +0200
changeset 35757
05981ff3fb7b
parent 35733
60a5d065ca81
child 35784
247f6f06531f
permissions
-rw-r--r--

Custom smileys: send them with xmpp

32445
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
1 /* pidgin
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
2 *
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
5 * source distribution.
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
6 *
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
7 * This program is free software; you can redistribute it and/or modify
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
8 * it under the terms of the GNU General Public License as published by
32445
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
10 * (at your option) any later version.
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
11 *
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
12 * This program is distributed in the hope that it will be useful,
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
15 * GNU General Public License for more details.
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
16 *
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
17 * You should have received a copy of the GNU General Public License
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
18 * along with this program; if not, write to the Free Software
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
20 *
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
21 */
a14d94db0df0 cleaning up code.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32441
diff changeset
22
32791
a2dc8d3ee1b8 Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32774
diff changeset
23 #include "internal.h"
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
24 #include "debug.h"
35194
9a0203562da5 pidgin: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents: 35129
diff changeset
25 #include "glibcompat.h"
32791
a2dc8d3ee1b8 Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32774
diff changeset
26 #include "pidgin.h"
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
27
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
28 #include <gdk/gdkkeysyms.h>
35194
9a0203562da5 pidgin: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents: 35129
diff changeset
29
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
30 #include "gtkutils.h"
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
31 #include "gtkwebview.h"
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
32 #include "gtkwebviewtoolbar.h"
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
33
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
34 #include "gtkinternal.h"
33170
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33167
diff changeset
35 #include "gtk3compat.h"
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33167
diff changeset
36
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
37 #define MAX_FONT_SIZE 7
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
38 #define MAX_SCROLL_TIME 0.4 /* seconds */
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
39 #define SCROLL_DELAY 33 /* milliseconds */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
40 #define PIDGIN_WEBVIEW_MAX_PROCESS_TIME 100000 /* microseconds */
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
41
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
42 #define PIDGIN_WEBVIEW_GET_PRIVATE(obj) \
35506
4252b2882889 Fix some remaining GTK_* macros as Elliott noticed
Ankit Vani <a@nevitus.org>
parents: 35500
diff changeset
43 (G_TYPE_INSTANCE_GET_PRIVATE((obj), PIDGIN_TYPE_WEBVIEW, PidginWebViewPriv))
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
44
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
45 enum {
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
46 LOAD_HTML,
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
47 LOAD_JS
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
48 };
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
49
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
50 enum {
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
51 BUTTONS_UPDATE,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
52 TOGGLE_FORMAT,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
53 CLEAR_FORMAT,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
54 UPDATE_FORMAT,
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
55 CHANGED,
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
56 HTML_APPENDED,
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
57 LAST_SIGNAL
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
58 };
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
59 static guint signals[LAST_SIGNAL] = { 0 };
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
60
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
61 /******************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
62 * Structs
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
63 *****************************************************************************/
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
64
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
65 typedef struct {
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
66 WebKitWebInspector *inspector;
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
67 WebKitDOMNode *node;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
68 } PidginWebViewInspectData;
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
69
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
70 typedef struct {
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
71 WebKitWebView *webview;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
72 gunichar ch;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
73 } PidginWebViewInsertData;
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
74
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
75 typedef struct {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
76 const char *label;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
77 gunichar ch;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
78 } GtkUnicodeMenuEntry;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
79
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
80 typedef struct {
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
81 char *name;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
82 int length;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
83
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
84 gboolean (*activate)(PidginWebView *webview, const char *uri);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
85 gboolean (*context_menu)(PidginWebView *webview, WebKitDOMHTMLAnchorElement *link, GtkWidget *menu);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
86 } PidginWebViewProtocol;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
87
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
88 typedef struct _PidginWebViewPriv {
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
89 /* Processing queues */
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
90 gboolean is_loading;
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
91 GQueue *load_queue;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
92 guint loader;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
93
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
94 /* Scroll adjustments */
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
95 GtkAdjustment *vadj;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
96 gboolean autoscroll;
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
97 guint scroll_src;
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
98 GTimer *scroll_time;
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
99
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
100 /* Format options */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
101 PidginWebViewButtons format_functions;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
102 PidginWebViewToolbar *toolbar;
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
103 struct {
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
104 gboolean wbfo:1; /* Whole buffer formatting only. */
33010
aa658ddce5ec Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33009
diff changeset
105 gboolean block_changed:1;
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
106 } edit;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
107
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
108 /* WebKit inspector */
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
109 WebKitWebView *inspector_view;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
110 GtkWindow *inspector_win;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
111 } PidginWebViewPriv;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
112
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
113 /******************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
114 * Globals
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
115 *****************************************************************************/
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
116
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
117 static WebKitWebViewClass *parent_class = NULL;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
118
35671
d1cc97d667a2 Box PidginSmiley and PidginWebViewSmiley
Ankit Vani <a@nevitus.org>
parents: 35648
diff changeset
119
33256
2bf06f291ff7 Add some smiley stuff to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33254
diff changeset
120 /******************************************************************************
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
121 * Helpers
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
122 *****************************************************************************/
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
123
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
124 static void
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
125 webview_resource_loading(WebKitWebView *webview,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
126 WebKitWebFrame *frame,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
127 WebKitWebResource *resource,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
128 WebKitNetworkRequest *request,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
129 WebKitNetworkResponse *response,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
130 gpointer user_data)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
131 {
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
132 const gchar *uri;
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
133 PurpleStoredImage *img = NULL;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
134 const char *filename;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
135
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
136 uri = webkit_network_request_get_uri(request);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
137 if (purple_str_has_prefix(uri, PURPLE_STORED_IMAGE_PROTOCOL)) {
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
138 int id;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
139
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
140 uri += sizeof(PURPLE_STORED_IMAGE_PROTOCOL) - 1;
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
141 id = strtoul(uri, NULL, 10);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
142
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
143 img = purple_imgstore_find_by_id(id);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
144 if (!img)
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
145 return;
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
146 } else if (purple_str_has_prefix(uri, PURPLE_STOCK_IMAGE_PROTOCOL)) {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
147 gchar *p_uri, *found;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
148 const gchar *domain, *stock_name;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
149
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
150 uri += sizeof(PURPLE_STOCK_IMAGE_PROTOCOL) - 1;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
151
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
152 p_uri = g_strdup(uri);
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
153 found = strchr(p_uri, '/');
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
154 if (!found) {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
155 purple_debug_warning("webview", "Invalid purple stock "
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
156 "image uri: %s", uri);
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
157 return;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
158 }
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
159
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
160 found[0] = '\0';
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
161 domain = p_uri;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
162 stock_name = found + 1;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
163
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
164 if (g_strcmp0(domain, "e2ee") == 0) {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
165 img = _pidgin_e2ee_stock_icon_get(stock_name);
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
166 if (!img)
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
167 return;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
168 } else {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
169 purple_debug_warning("webview", "Invalid purple stock "
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
170 "image domain: %s", domain);
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
171 return;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
172 }
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
173 } else
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
174 return;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
175
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
176 if (img != NULL) {
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
177 filename = purple_imgstore_get_filename(img);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
178 if (filename && g_path_is_absolute(filename)) {
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
179 gchar *tmp = g_strdup_printf("file://%s", filename);
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
180 webkit_network_request_set_uri(request, tmp);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
181 g_free(tmp);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
182 } else {
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
183 gchar *b64, *tmp;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
184 const gchar *type;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
185
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
186 b64 = purple_base64_encode(
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
187 purple_imgstore_get_data(img),
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
188 purple_imgstore_get_size(img));
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
189 type = purple_imgstore_get_extension(img);
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
190 tmp = g_strdup_printf("data:image/%s;base64,%s",
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
191 type, b64);
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
192 webkit_network_request_set_uri(request, tmp);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
193 g_free(b64);
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
194 g_free(tmp);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
195 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
196 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
197 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
198
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
199 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
200 process_load_queue_element(PidginWebView *webview)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
201 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
202 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
203 int type;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
204 char *str;
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
205 WebKitDOMDocument *doc;
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
206 WebKitDOMHTMLElement *body;
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
207 WebKitDOMNode *start, *end;
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
208 WebKitDOMRange *range;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
209 gboolean require_scroll = FALSE;
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
210
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
211 type = GPOINTER_TO_INT(g_queue_pop_head(priv->load_queue));
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
212 str = g_queue_pop_head(priv->load_queue);
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
213
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
214 switch (type) {
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
215 case LOAD_HTML:
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
216 doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
217 body = webkit_dom_document_get_body(doc);
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
218 start = webkit_dom_node_get_last_child(WEBKIT_DOM_NODE(body));
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
219
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
220 if (priv->autoscroll) {
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
221 require_scroll = (gtk_adjustment_get_value(priv->vadj)
33253
716af5e03402 Tweak autoscrolling limits to get filtered debug window to work.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33250
diff changeset
222 >= (gtk_adjustment_get_upper(priv->vadj) -
716af5e03402 Tweak autoscrolling limits to get filtered debug window to work.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33250
diff changeset
223 1.5*gtk_adjustment_get_page_size(priv->vadj)));
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
224 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
225
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
226 webkit_dom_html_element_insert_adjacent_html(body, "beforeend",
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
227 str, NULL);
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
228
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
229 range = webkit_dom_document_create_range(doc);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
230 if (start) {
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
231 end = webkit_dom_node_get_last_child(WEBKIT_DOM_NODE(body));
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
232 webkit_dom_range_set_start_after(range,
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
233 WEBKIT_DOM_NODE(start),
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
234 NULL);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
235 webkit_dom_range_set_end_after(range,
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
236 WEBKIT_DOM_NODE(end),
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
237 NULL);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
238 } else {
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
239 webkit_dom_range_select_node_contents(range,
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
240 WEBKIT_DOM_NODE(body),
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
241 NULL);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
242 }
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
243
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
244 if (require_scroll) {
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
245 if (start)
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
246 webkit_dom_element_scroll_into_view(WEBKIT_DOM_ELEMENT(start),
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
247 TRUE);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
248 else
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
249 webkit_dom_element_scroll_into_view(WEBKIT_DOM_ELEMENT(body),
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
250 TRUE);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
251 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
252
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
253 g_signal_emit(webview, signals[HTML_APPENDED], 0, range);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
254
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
255 break;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
256
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
257 case LOAD_JS:
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
258 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), str);
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
259 break;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
260
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
261 default:
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
262 purple_debug_error("webview",
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
263 "Got unknown loading queue type: %d\n", type);
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
264 break;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
265 }
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
266
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
267 g_free(str);
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
268 }
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
269
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
270 static gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
271 process_load_queue(PidginWebView *webview)
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
272 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
273 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
274 gint64 start_time;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
275
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
276 if (priv->is_loading) {
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
277 priv->loader = 0;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
278 return FALSE;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
279 }
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
280 if (!priv->load_queue || g_queue_is_empty(priv->load_queue)) {
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
281 priv->loader = 0;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
282 return FALSE;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
283 }
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
284
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
285 start_time = g_get_monotonic_time();
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
286 while (!g_queue_is_empty(priv->load_queue)) {
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
287 process_load_queue_element(webview);
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
288 if (g_get_monotonic_time() - start_time >
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
289 PIDGIN_WEBVIEW_MAX_PROCESS_TIME)
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
290 break;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
291 }
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
292
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
293 if (g_queue_is_empty(priv->load_queue)) {
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
294 priv->loader = 0;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
295 return FALSE;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
296 }
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
297 return TRUE;
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
298 }
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
299
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
300 static void
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
301 webview_load_started(WebKitWebView *webview, WebKitWebFrame *frame,
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
302 gpointer userdata)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
303 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
304 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
305
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
306 /* is there a better way to test for is_loading? */
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
307 priv->is_loading = TRUE;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
308 }
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
309
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
310 static void
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
311 webview_load_finished(WebKitWebView *webview, WebKitWebFrame *frame,
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
312 gpointer userdata)
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
313 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
314 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
315
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
316 priv->is_loading = FALSE;
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
317 if (priv->loader == 0)
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
318 priv->loader = g_idle_add((GSourceFunc)process_load_queue, webview);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
319 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
320
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
321 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
322 webview_inspector_inspect_element(GtkWidget *item, PidginWebViewInspectData *data)
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
323 {
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
324 webkit_web_inspector_inspect_node(data->inspector, data->node);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
325 }
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
326
34464
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
327 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
328 webview_inspector_destroy(GtkWindow *window, PidginWebViewPriv *priv)
34464
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
329 {
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
330 g_return_if_fail(priv->inspector_win == window);
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
331
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
332 priv->inspector_win = NULL;
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
333 priv->inspector_view = NULL;
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
334 }
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
335
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
336 static WebKitWebView *
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
337 webview_inspector_create(WebKitWebInspector *inspector,
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
338 WebKitWebView *webview, gpointer _unused)
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
339 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
340 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
341
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
342 if (priv->inspector_view != NULL)
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
343 return priv->inspector_view;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
344
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
345 priv->inspector_win = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
346 gtk_window_set_title(priv->inspector_win, _("WebKit inspector"));
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
347 gtk_window_set_default_size(priv->inspector_win, 600, 400);
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
348
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
349 priv->inspector_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
350 gtk_container_add(GTK_CONTAINER(priv->inspector_win),
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
351 GTK_WIDGET(priv->inspector_view));
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
352
34464
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
353 g_signal_connect(priv->inspector_win, "destroy",
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
354 G_CALLBACK(webview_inspector_destroy), priv);
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
355
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
356 return priv->inspector_view;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
357 }
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
358
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
359 static gboolean
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
360 webview_inspector_show(WebKitWebInspector *inspector, GtkWidget *webview)
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
361 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
362 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
363
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
364 gtk_widget_show_all(GTK_WIDGET(priv->inspector_win));
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
365
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
366 return TRUE;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
367 }
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
368
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
369 static PidginWebViewProtocol *
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
370 webview_find_protocol(const char *url, gboolean reverse)
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
371 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
372 PidginWebViewClass *klass;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
373 GList *iter;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
374 PidginWebViewProtocol *proto = NULL;
34308
cdb187c27360 Fix the rest of Pidgin's warnings about -Wsign-compare; remove -Wno-sign-compare from cflags
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34299
diff changeset
375 gssize length = reverse ? (gssize)strlen(url) : -1;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
376
35506
4252b2882889 Fix some remaining GTK_* macros as Elliott noticed
Ankit Vani <a@nevitus.org>
parents: 35500
diff changeset
377 klass = g_type_class_ref(PIDGIN_TYPE_WEBVIEW);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
378 for (iter = klass->protocols; iter; iter = iter->next) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
379 proto = iter->data;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
380 if (g_ascii_strncasecmp(url, proto->name, reverse ? MIN(length, proto->length) : proto->length) == 0) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
381 g_type_class_unref(klass);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
382 return proto;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
383 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
384 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
385
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
386 g_type_class_unref(klass);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
387 return NULL;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
388 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
389
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
390 static gboolean
33226
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
391 webview_navigation_decision(WebKitWebView *webview,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
392 WebKitWebFrame *frame,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
393 WebKitNetworkRequest *request,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
394 WebKitWebNavigationAction *navigation_action,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
395 WebKitWebPolicyDecision *policy_decision,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
396 gpointer userdata)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
397 {
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
398 const gchar *uri;
32506
74d884939a2c Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32502
diff changeset
399 WebKitWebNavigationReason reason;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
400
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
401 uri = webkit_network_request_get_uri(request);
32506
74d884939a2c Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32502
diff changeset
402 reason = webkit_web_navigation_action_get_reason(navigation_action);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
403
32506
74d884939a2c Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32502
diff changeset
404 if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
405 PidginWebViewProtocol *proto = webview_find_protocol(uri, FALSE);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
406 if (proto) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
407 /* XXX: Do something with the return value? */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
408 proto->activate(PIDGIN_WEBVIEW(webview), uri);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
409 }
32800
67649fafdb51 If we handle a navigation request, then we should tell WebKit
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32799
diff changeset
410 webkit_web_policy_decision_ignore(policy_decision);
32803
a2d80b30be13 We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32800
diff changeset
411 } else if (reason == WEBKIT_WEB_NAVIGATION_REASON_OTHER)
32523
2d37b68228b6 Let webview manage the navigation ONLY if the reason is the user clicked a link.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32513
diff changeset
412 webkit_web_policy_decision_use(policy_decision);
32803
a2d80b30be13 We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32800
diff changeset
413 else
a2d80b30be13 We don't want WebKit to process a Refresh, or Back/Forward
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32800
diff changeset
414 webkit_web_policy_decision_ignore(policy_decision);
32506
74d884939a2c Handle better webkit's navigation-policy-decision-requested signal to be able to manage external files, links and theme files.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32502
diff changeset
415
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
416 return TRUE;
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
417 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
418
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
419 static GtkWidget *
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
420 get_input_methods_menu(WebKitWebView *webview)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
421 {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
422 GtkSettings *settings;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
423 gboolean show = TRUE;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
424 GtkWidget *item;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
425 GtkWidget *menu;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
426 GtkIMContext *im;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
427
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
428 settings = webview ? gtk_widget_get_settings(GTK_WIDGET(webview)) : gtk_settings_get_default();
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
429
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
430 if (settings)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
431 g_object_get(settings, "gtk-show-input-method-menu", &show, NULL);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
432 if (!show)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
433 return NULL;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
434
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
435 item = gtk_image_menu_item_new_with_mnemonic(_("Input _Methods"));
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
436
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
437 g_object_get(webview, "im-context", &im, NULL);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
438 menu = gtk_menu_new();
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
439 gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(im),
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
440 GTK_MENU_SHELL(menu));
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
441 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
442
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
443 return item;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
444 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
445
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
446 /* Values taken from gtktextutil.c */
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
447 static const GtkUnicodeMenuEntry bidi_menu_entries[] = {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
448 { N_("LRM _Left-to-right mark"), 0x200E },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
449 { N_("RLM _Right-to-left mark"), 0x200F },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
450 { N_("LRE Left-to-right _embedding"), 0x202A },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
451 { N_("RLE Right-to-left e_mbedding"), 0x202B },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
452 { N_("LRO Left-to-right _override"), 0x202D },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
453 { N_("RLO Right-to-left o_verride"), 0x202E },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
454 { N_("PDF _Pop directional formatting"), 0x202C },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
455 { N_("ZWS _Zero width space"), 0x200B },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
456 { N_("ZWJ Zero width _joiner"), 0x200D },
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
457 { N_("ZWNJ Zero width _non-joiner"), 0x200C }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
458 };
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
459
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
460 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
461 insert_control_character_cb(GtkMenuItem *item, PidginWebViewInsertData *data)
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
462 {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
463 WebKitWebView *webview = data->webview;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
464 gunichar ch = data->ch;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
465 PidginWebViewPriv *priv;
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
466 WebKitDOMDocument *dom;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
467 char buf[6];
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
468
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
469 priv = PIDGIN_WEBVIEW_GET_PRIVATE(PIDGIN_WEBVIEW(webview));
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
470 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
471
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
472 g_unichar_to_utf8(ch, buf);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
473 priv->edit.block_changed = TRUE;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
474 webkit_dom_document_exec_command(dom, "insertHTML", FALSE, buf);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
475 priv->edit.block_changed = FALSE;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
476 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
477
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
478 static GtkWidget *
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
479 get_unicode_menu(WebKitWebView *webview)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
480 {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
481 GtkSettings *settings;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
482 gboolean show = TRUE;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
483 GtkWidget *menuitem;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
484 GtkWidget *menu;
34308
cdb187c27360 Fix the rest of Pidgin's warnings about -Wsign-compare; remove -Wno-sign-compare from cflags
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34299
diff changeset
485 gsize i;
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
486
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
487 settings = webview ? gtk_widget_get_settings(GTK_WIDGET(webview)) : gtk_settings_get_default();
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
488
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
489 if (settings)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
490 g_object_get(settings, "gtk-show-unicode-menu", &show, NULL);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
491 if (!show)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
492 return NULL;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
493
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
494 menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Insert Unicode Control Character"));
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
495
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
496 menu = gtk_menu_new();
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
497 for (i = 0; i < G_N_ELEMENTS(bidi_menu_entries); i++) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
498 PidginWebViewInsertData *data;
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
499 GtkWidget *item;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
500
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
501 data = g_new0(PidginWebViewInsertData, 1);
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
502 data->webview = webview;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
503 data->ch = bidi_menu_entries[i].ch;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
504
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
505 item = gtk_menu_item_new_with_mnemonic(_(bidi_menu_entries[i].label));
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
506 g_signal_connect_data(item, "activate",
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
507 G_CALLBACK(insert_control_character_cb), data,
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
508 (GClosureNotify)g_free, 0);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
509 gtk_widget_show(item);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
510 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
511 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
512
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
513 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
514
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
515 return menuitem;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
516 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
517
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
518 static void
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
519 do_popup_menu(WebKitWebView *webview, int button, int time, int context,
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
520 WebKitDOMNode *node, const char *uri)
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
521 {
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
522 GtkWidget *menu;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
523 GtkWidget *cut, *copy, *paste, *delete, *select;
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
524
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
525 menu = gtk_menu_new();
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
526 g_signal_connect(menu, "selection-done",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
527 G_CALLBACK(gtk_widget_destroy), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
528
33233
26a3100b451e Don't show link context menu when it's part of the selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33232
diff changeset
529 if ((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
26a3100b451e Don't show link context menu when it's part of the selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33232
diff changeset
530 && !(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION)) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
531 PidginWebViewProtocol *proto = NULL;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
532 GList *children;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
533
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
534 while (node && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(node)) {
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
535 node = webkit_dom_node_get_parent_node(node);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
536 }
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
537
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
538 if (uri && node)
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
539 proto = webview_find_protocol(uri, FALSE);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
540
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
541 if (proto && proto->context_menu) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
542 proto->context_menu(PIDGIN_WEBVIEW(webview),
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
543 WEBKIT_DOM_HTML_ANCHOR_ELEMENT(node), menu);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
544 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
545
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
546 children = gtk_container_get_children(GTK_CONTAINER(menu));
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
547 if (!children) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
548 GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available"));
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
549 gtk_widget_show(item);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
550 gtk_widget_set_sensitive(item, FALSE);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
551 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
552 } else {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
553 g_list_free(children);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
554 }
33232
a572083f80ef Register protocols with GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33231
diff changeset
555 gtk_widget_show_all(menu);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
556
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
557 } else {
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
558 /* Using connect_swapped means we don't need any wrapper functions */
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
559 cut = pidgin_new_item_from_stock(menu, _("Cu_t"), GTK_STOCK_CUT,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
560 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
561 g_signal_connect_swapped(G_OBJECT(cut), "activate",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
562 G_CALLBACK(webkit_web_view_cut_clipboard),
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
563 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
564
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
565 copy = pidgin_new_item_from_stock(menu, _("_Copy"), GTK_STOCK_COPY,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
566 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
567 g_signal_connect_swapped(G_OBJECT(copy), "activate",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
568 G_CALLBACK(webkit_web_view_copy_clipboard),
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
569 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
570
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
571 paste = pidgin_new_item_from_stock(menu, _("_Paste"), GTK_STOCK_PASTE,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
572 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
573 g_signal_connect_swapped(G_OBJECT(paste), "activate",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
574 G_CALLBACK(webkit_web_view_paste_clipboard),
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
575 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
576
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
577 delete = pidgin_new_item_from_stock(menu, _("_Delete"), GTK_STOCK_DELETE,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
578 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
579 g_signal_connect_swapped(G_OBJECT(delete), "activate",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
580 G_CALLBACK(webkit_web_view_delete_selection),
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
581 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
582
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
583 pidgin_separator(menu);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
584
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
585 select = pidgin_new_item_from_stock(menu, _("Select _All"),
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
586 GTK_STOCK_SELECT_ALL,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
587 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
588 g_signal_connect_swapped(G_OBJECT(select), "activate",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
589 G_CALLBACK(webkit_web_view_select_all),
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
590 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
591
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
592 gtk_widget_set_sensitive(cut,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
593 webkit_web_view_can_cut_clipboard(webview));
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
594 gtk_widget_set_sensitive(copy,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
595 webkit_web_view_can_copy_clipboard(webview));
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
596 gtk_widget_set_sensitive(paste,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
597 webkit_web_view_can_paste_clipboard(webview));
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
598 gtk_widget_set_sensitive(delete,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
599 webkit_web_view_can_cut_clipboard(webview));
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
600 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
601
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
602 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
603 "/webview/inspector_enabled"))
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
604 {
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
605 WebKitWebSettings *settings;
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
606 GtkWidget *inspect;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
607 PidginWebViewInspectData *data;
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
608
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
609 settings = webkit_web_view_get_settings(webview);
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
610 g_object_set(G_OBJECT(settings), "enable-developer-extras", TRUE, NULL);
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
611
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
612 data = g_new0(PidginWebViewInspectData, 1);
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
613 data->inspector = webkit_web_view_get_inspector(webview);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
614 data->node = node;
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
615
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
616 pidgin_separator(menu);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
617
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
618 inspect = pidgin_new_item_from_stock(menu, _("Inspect _Element"), NULL,
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
619 NULL, NULL, 0, 0, NULL);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
620 g_signal_connect_data(G_OBJECT(inspect), "activate",
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
621 G_CALLBACK(webview_inspector_inspect_element),
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
622 data, (GClosureNotify)g_free, 0);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
623 }
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
624
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
625 if (webkit_web_view_get_editable(webview)) {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
626 GtkWidget *im = get_input_methods_menu(webview);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
627 GtkWidget *unicode = get_unicode_menu(webview);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
628
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
629 if (im || unicode)
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
630 pidgin_separator(menu);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
631
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
632 if (im) {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
633 gtk_menu_shell_append(GTK_MENU_SHELL(menu), im);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
634 gtk_widget_show(im);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
635 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
636
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
637 if (unicode) {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
638 gtk_menu_shell_append(GTK_MENU_SHELL(menu), unicode);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
639 gtk_widget_show(unicode);
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
640 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
641 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
642
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
643 g_signal_emit_by_name(G_OBJECT(webview), "populate-popup", menu);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
644
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
645 gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(webview), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
646 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
647 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
648
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
649 static gboolean
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
650 webview_popup_menu(WebKitWebView *webview)
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
651 {
33250
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
652 WebKitDOMDocument *doc;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
653 WebKitDOMElement *active;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
654 WebKitDOMElement *link;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
655 int context;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
656 char *uri;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
657
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
658 context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
659 uri = NULL;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
660
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
661 doc = webkit_web_view_get_dom_document(webview);
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
662 active = webkit_dom_html_document_get_active_element(WEBKIT_DOM_HTML_DOCUMENT(doc));
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
663
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
664 link = active;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
665 while (link && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link))
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
666 link = webkit_dom_node_get_parent_element(WEBKIT_DOM_NODE(link));
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
667 if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) {
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
668 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
669 uri = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link));
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
670 }
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
671
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
672 do_popup_menu(webview, 0, gtk_get_current_event_time(),
33250
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
673 context, WEBKIT_DOM_NODE(active), uri);
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
674
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
675 g_free(uri);
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
676
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
677 return TRUE;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
678 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
679
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
680 static gboolean
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
681 webview_button_pressed(WebKitWebView *webview, GdkEventButton *event)
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
682 {
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
683 if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
684 WebKitHitTestResult *hit;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
685 int context;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
686 WebKitDOMNode *node;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
687 char *uri;
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
688
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
689 hit = webkit_web_view_get_hit_test_result(webview, event);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
690 g_object_get(G_OBJECT(hit),
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
691 "context", &context,
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
692 "inner-node", &node,
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
693 "link-uri", &uri,
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
694 NULL);
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
695
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
696 do_popup_menu(webview, event->button, event->time, context,
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
697 node, uri);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
698
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
699 g_free(uri);
33500
d6de39919ac3 Fix leak of the WebKitHitTestResult.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33265
diff changeset
700 g_object_unref(hit);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
701
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
702 return TRUE;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
703 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
704
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
705 return FALSE;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
706 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
707
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
708 /*
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
709 * Smoothly scroll a WebView.
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
710 *
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
711 * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom.
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
712 */
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
713 static gboolean
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
714 smooth_scroll_cb(gpointer data)
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
715 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
716 PidginWebViewPriv *priv = data;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
717 GtkAdjustment *adj;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
718 gdouble max_val;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
719 gdouble scroll_val;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
720
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
721 g_return_val_if_fail(priv->scroll_time != NULL, FALSE);
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
722
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
723 adj = priv->vadj;
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
724 max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
725 scroll_val = gtk_adjustment_get_value(adj) +
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
726 ((max_val - gtk_adjustment_get_value(adj)) / 3);
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
727
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
728 if (g_timer_elapsed(priv->scroll_time, NULL) > MAX_SCROLL_TIME
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
729 || scroll_val >= max_val) {
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
730 /* time's up. jump to the end and kill the timer */
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
731 gtk_adjustment_set_value(adj, max_val);
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
732 g_timer_destroy(priv->scroll_time);
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
733 priv->scroll_time = NULL;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
734 priv->scroll_src = 0;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
735 return FALSE;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
736 }
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
737
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
738 /* scroll by 1/3rd the remaining distance */
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
739 gtk_adjustment_set_value(adj, scroll_val);
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
740 return TRUE;
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
741 }
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
742
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
743 static gboolean
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
744 scroll_idle_cb(gpointer data)
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
745 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
746 PidginWebViewPriv *priv = data;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
747 GtkAdjustment *adj = priv->vadj;
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
748 gdouble max_val;
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
749
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
750 if (adj) {
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
751 max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj);
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
752 gtk_adjustment_set_value(adj, max_val);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
753 }
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
754
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
755 priv->scroll_src = 0;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
756 return FALSE;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
757 }
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
758
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
759 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
760 emit_format_signal(PidginWebView *webview, PidginWebViewButtons buttons)
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
761 {
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
762 g_object_ref(webview);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
763 g_signal_emit(webview, signals[TOGGLE_FORMAT], 0, buttons);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
764 g_object_unref(webview);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
765 }
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
766
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
767 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
768 do_formatting(PidginWebView *webview, const char *name, const char *value)
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
769 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
770 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
771 WebKitDOMDocument *dom;
33022
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
772 WebKitDOMDOMWindow *win;
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
773 WebKitDOMDOMSelection *sel = NULL;
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
774 WebKitDOMRange *range = NULL;
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
775
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
776 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
777
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
778 if (priv->edit.wbfo) {
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
779 win = webkit_dom_document_get_default_view(dom);
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
780 sel = webkit_dom_dom_window_get_selection(win);
33022
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
781 if (webkit_dom_dom_selection_get_range_count(sel) > 0)
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
782 range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
783 webkit_web_view_select_all(WEBKIT_WEB_VIEW(webview));
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
784 }
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
785
33010
aa658ddce5ec Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33009
diff changeset
786 priv->edit.block_changed = TRUE;
35194
9a0203562da5 pidgin: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents: 35129
diff changeset
787 webkit_dom_document_exec_command(dom, (gchar *)name, FALSE, (gchar *)value);
33010
aa658ddce5ec Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33009
diff changeset
788 priv->edit.block_changed = FALSE;
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
789
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
790 if (priv->edit.wbfo) {
33022
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
791 if (range) {
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
792 webkit_dom_dom_selection_remove_all_ranges(sel);
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
793 webkit_dom_dom_selection_add_range(sel, range);
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
794 } else {
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
795 webkit_dom_dom_selection_collapse_to_end(sel, NULL);
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
796 }
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
797 }
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
798 }
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
799
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
800 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
801 webview_font_shrink(PidginWebView *webview)
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
802 {
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
803 gint fontsize;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
804 char *tmp;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
805
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
806 fontsize = pidgin_webview_get_current_fontsize(webview);
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
807 fontsize = MAX(fontsize - 1, 1);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
808
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
809 tmp = g_strdup_printf("%d", fontsize);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
810 do_formatting(webview, "fontSize", tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
811 g_free(tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
812 }
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
813
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
814 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
815 webview_font_grow(PidginWebView *webview)
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
816 {
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
817 gint fontsize;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
818 char *tmp;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
819
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
820 fontsize = pidgin_webview_get_current_fontsize(webview);
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
821 fontsize = MIN(fontsize + 1, MAX_FONT_SIZE);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
822
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
823 tmp = g_strdup_printf("%d", fontsize);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
824 do_formatting(webview, "fontSize", tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
825 g_free(tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
826 }
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
827
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
828 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
829 webview_clear_formatting(PidginWebView *webview)
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
830 {
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
831 if (!webkit_web_view_get_editable(WEBKIT_WEB_VIEW(webview)))
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
832 return;
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
833
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
834 do_formatting(webview, "removeFormat", "");
33020
03c013f8990c Remove links and background colours on format-clear.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33018
diff changeset
835 do_formatting(webview, "unlink", "");
03c013f8990c Remove links and background colours on format-clear.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33018
diff changeset
836 do_formatting(webview, "backColor", "inherit");
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
837 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
838
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
839 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
840 webview_toggle_format(PidginWebView *webview, PidginWebViewButtons buttons)
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
841 {
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
842 /* since this function is the handler for the formatting keystrokes,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
843 we need to check here that the formatting attempted is permitted */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
844 buttons &= pidgin_webview_get_format_functions(webview);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
845
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
846 switch (buttons) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
847 case PIDGIN_WEBVIEW_BOLD:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
848 do_formatting(webview, "bold", "");
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
849 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
850 case PIDGIN_WEBVIEW_ITALIC:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
851 do_formatting(webview, "italic", "");
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
852 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
853 case PIDGIN_WEBVIEW_UNDERLINE:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
854 do_formatting(webview, "underline", "");
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
855 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
856 case PIDGIN_WEBVIEW_STRIKE:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
857 do_formatting(webview, "strikethrough", "");
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
858 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
859 case PIDGIN_WEBVIEW_SHRINK:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
860 webview_font_shrink(webview);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
861 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
862 case PIDGIN_WEBVIEW_GROW:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
863 webview_font_grow(webview);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
864 break;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
865 default:
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
866 break;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
867 }
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
868 }
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
869
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
870 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
871 editable_input_cb(PidginWebView *webview, gpointer data)
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
872 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
873 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33030
4114ce42d094 Don't emit changed signal when a webview is insensitive.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33028
diff changeset
874 if (!priv->edit.block_changed && gtk_widget_is_sensitive(GTK_WIDGET(webview)))
33010
aa658ddce5ec Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33009
diff changeset
875 g_signal_emit(webview, signals[CHANGED], 0);
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
876 }
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
877
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
878 /******************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
879 * GObject Stuff
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
880 *****************************************************************************/
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
881
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
882 GtkWidget *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
883 pidgin_webview_new(gboolean editable)
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
884 {
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
885 GtkWidget *result;
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
886 WebKitWebView *webview;
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
887 WebKitWebSettings *settings;
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
888
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
889 result = g_object_new(pidgin_webview_get_type(), NULL);
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
890 webview = WEBKIT_WEB_VIEW(result);
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
891 settings = webkit_web_view_get_settings(webview);
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
892
33877
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
893 g_object_set(G_OBJECT(settings), "default-encoding", "utf-8", NULL);
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
894 #ifdef _WIN32
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
895 /* XXX: win32 WebKitGTK replaces backslash with yen sign for
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
896 * "sans-serif" font. We should figure out, how to disable this
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
897 * behavior, but for now I will just apply this simple hack (using other
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
898 * font family).
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
899 */
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
900 g_object_set(G_OBJECT(settings), "default-font-family", "Verdana", NULL);
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
901 #endif
d33b4fa5ea06 win32: hack for webkit's feature of replacing backslash with yen sign; silencing some warnings in gtkconv.c; consistent messages in proxy.c
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33857
diff changeset
902 webkit_web_view_set_settings(webview, settings);
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
903
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
904 if (editable) {
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
905 webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable);
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
906
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
907 g_signal_connect(G_OBJECT(webview), "user-changed-contents",
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
908 G_CALLBACK(editable_input_cb), NULL);
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
909 }
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
910
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
911 return result;
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
912 }
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
913
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
914 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
915 pidgin_webview_finalize(GObject *webview)
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
916 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
917 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
918
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
919 if (priv->inspector_win != NULL)
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
920 gtk_widget_destroy(GTK_WIDGET(priv->inspector_win));
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
921
33227
2541e55ae19d Only remove source if non-zero.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33226
diff changeset
922 if (priv->loader)
2541e55ae19d Only remove source if non-zero.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33226
diff changeset
923 g_source_remove(priv->loader);
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
924
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
925 while (!g_queue_is_empty(priv->load_queue)) {
35689
1e257009ac10 Fix Pidgin clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35671
diff changeset
926 g_queue_pop_head(priv->load_queue);
1e257009ac10 Fix Pidgin clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35671
diff changeset
927 g_free(g_queue_pop_head(priv->load_queue));
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
928 }
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
929 g_queue_free(priv->load_queue);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
930
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
931 G_OBJECT_CLASS(parent_class)->finalize(G_OBJECT(webview));
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
932 }
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
933
35648
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
934 enum {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
935 PROP_0,
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
936 PROP_EXPAND
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
937 };
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
938
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
939 static void
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
940 pidgin_webview_set_property(GObject *object, guint prop_id, const GValue *value,
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
941 GParamSpec *pspec)
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
942 {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
943 g_return_if_fail(PIDGIN_IS_WEBVIEW(object));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
944
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
945 switch (prop_id) {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
946 case PROP_EXPAND:
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
947 purple_debug_misc("webview",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
948 "Ignored expand property (set to %d)",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
949 g_value_get_boolean(value));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
950 break;
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
951 default:
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
952 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
953 pspec);
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
954 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
955 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
956
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
957 static void
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
958 pidgin_webview_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
959 {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
960 g_return_if_fail(PIDGIN_IS_WEBVIEW(object));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
961
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
962 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
963 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
964
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
965 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
966 pidgin_webview_class_init(PidginWebViewClass *klass, gpointer userdata)
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
967 {
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
968 GObjectClass *gobject_class;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
969 GtkBindingSet *binding_set;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
970
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
971 parent_class = g_type_class_ref(webkit_web_view_get_type());
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
972 gobject_class = G_OBJECT_CLASS(klass);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
973
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
974 g_type_class_add_private(klass, sizeof(PidginWebViewPriv));
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
975
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
976 /* Signals */
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
977
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
978 signals[BUTTONS_UPDATE] = g_signal_new("allowed-formats-updated",
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
979 G_TYPE_FROM_CLASS(gobject_class),
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
980 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
981 G_STRUCT_OFFSET(PidginWebViewClass, buttons_update),
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
982 NULL, 0, g_cclosure_marshal_VOID__INT,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
983 G_TYPE_NONE, 1, G_TYPE_INT);
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
984 signals[TOGGLE_FORMAT] = g_signal_new("format-toggled",
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
985 G_TYPE_FROM_CLASS(gobject_class),
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
986 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
987 G_STRUCT_OFFSET(PidginWebViewClass, toggle_format),
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
988 NULL, 0, g_cclosure_marshal_VOID__INT,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
989 G_TYPE_NONE, 1, G_TYPE_INT);
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
990 signals[CLEAR_FORMAT] = g_signal_new("format-cleared",
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
991 G_TYPE_FROM_CLASS(gobject_class),
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
992 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
993 G_STRUCT_OFFSET(PidginWebViewClass, clear_format),
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
994 NULL, 0, g_cclosure_marshal_VOID__VOID,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
995 G_TYPE_NONE, 0);
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
996 signals[UPDATE_FORMAT] = g_signal_new("format-updated",
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
997 G_TYPE_FROM_CLASS(gobject_class),
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
998 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
999 G_STRUCT_OFFSET(PidginWebViewClass, update_format),
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1000 NULL, 0, g_cclosure_marshal_VOID__VOID,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1001 G_TYPE_NONE, 0);
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1002 signals[CHANGED] = g_signal_new("changed",
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1003 G_TYPE_FROM_CLASS(gobject_class),
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1004 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1005 G_STRUCT_OFFSET(PidginWebViewClass, changed),
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1006 NULL, NULL, g_cclosure_marshal_VOID__VOID,
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1007 G_TYPE_NONE, 0);
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1008 signals[HTML_APPENDED] = g_signal_new("html-appended",
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1009 G_TYPE_FROM_CLASS(gobject_class),
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1010 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1011 G_STRUCT_OFFSET(PidginWebViewClass, html_appended),
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1012 NULL, NULL,
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1013 g_cclosure_marshal_VOID__OBJECT,
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1014 G_TYPE_NONE, 1, WEBKIT_TYPE_DOM_RANGE,
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
1015 NULL);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1016
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1017 /* Class Methods */
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1018
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1019 klass->toggle_format = webview_toggle_format;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1020 klass->clear_format = webview_clear_formatting;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1021
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1022 gobject_class->finalize = pidgin_webview_finalize;
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1023
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1024 /* Key Bindings */
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1025
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1026 binding_set = gtk_binding_set_by_class(parent_class);
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1027 gtk_binding_entry_add_signal(binding_set, GDK_KEY_b, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1028 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1029 PIDGIN_WEBVIEW_BOLD);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1030 gtk_binding_entry_add_signal(binding_set, GDK_KEY_i, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1031 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1032 PIDGIN_WEBVIEW_ITALIC);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1033 gtk_binding_entry_add_signal(binding_set, GDK_KEY_u, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1034 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1035 PIDGIN_WEBVIEW_UNDERLINE);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1036 gtk_binding_entry_add_signal(binding_set, GDK_KEY_plus, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1037 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1038 PIDGIN_WEBVIEW_GROW);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1039 gtk_binding_entry_add_signal(binding_set, GDK_KEY_equal, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1040 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1041 PIDGIN_WEBVIEW_GROW);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1042 gtk_binding_entry_add_signal(binding_set, GDK_KEY_minus, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1043 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1044 PIDGIN_WEBVIEW_SHRINK);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1045
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1046 binding_set = gtk_binding_set_by_class(klass);
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1047 gtk_binding_entry_add_signal(binding_set, GDK_KEY_r, GDK_CONTROL_MASK,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1048 "format-cleared", 0);
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1049
35648
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1050 /* properties */
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1051
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1052 G_OBJECT_CLASS(klass)->set_property = pidgin_webview_set_property;
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1053 G_OBJECT_CLASS(klass)->get_property = pidgin_webview_get_property;
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1054
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1055 if (!g_object_class_find_property(G_OBJECT_CLASS(klass), "expand")) {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1056 /* webkitgtk for gtk2 doesn't seems to have this */
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1057 g_object_class_install_property(G_OBJECT_CLASS(klass),
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1058 PROP_EXPAND, g_param_spec_boolean("expand", "Expand Both",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1059 "Whether widget wants to expand in both directions",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1060 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1061 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1062
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1063 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/webview");
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1064 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/webview/inspector_enabled", FALSE);
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
1065 }
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
1066
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1067 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1068 pidgin_webview_init(PidginWebView *webview, gpointer userdata)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1069 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1070 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1071 WebKitWebInspector *inspector;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1072
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1073 priv->load_queue = g_queue_new();
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1074
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1075 g_signal_connect(G_OBJECT(webview), "button-press-event",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1076 G_CALLBACK(webview_button_pressed), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1077
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1078 g_signal_connect(G_OBJECT(webview), "popup-menu",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1079 G_CALLBACK(webview_popup_menu), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1080
33223
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1081 g_signal_connect(G_OBJECT(webview), "navigation-policy-decision-requested",
33226
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
1082 G_CALLBACK(webview_navigation_decision), NULL);
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
1083
33223
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1084 g_signal_connect(G_OBJECT(webview), "load-started",
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1085 G_CALLBACK(webview_load_started), NULL);
32460
5771be5530d8 safely execute JS scripts only after loading is done. Untested code as of now, will test it in next commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents: 32446
diff changeset
1086
33223
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1087 g_signal_connect(G_OBJECT(webview), "load-finished",
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1088 G_CALLBACK(webview_load_finished), NULL);
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1089
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1090 g_signal_connect(G_OBJECT(webview), "resource-request-starting",
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1091 G_CALLBACK(webview_resource_loading), NULL);
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1092
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1093 inspector = webkit_web_view_get_inspector(WEBKIT_WEB_VIEW(webview));
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1094 g_signal_connect(G_OBJECT(inspector), "inspect-web-view",
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1095 G_CALLBACK(webview_inspector_create), NULL);
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1096 g_signal_connect(G_OBJECT(inspector), "show-window",
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1097 G_CALLBACK(webview_inspector_show), webview);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1098 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1099
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1100 GType
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1101 pidgin_webview_get_type(void)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1102 {
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1103 static GType mview_type = 0;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1104 if (G_UNLIKELY(mview_type == 0)) {
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1105 static const GTypeInfo mview_info = {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1106 sizeof(PidginWebViewClass),
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1107 NULL,
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1108 NULL,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1109 (GClassInitFunc)pidgin_webview_class_init,
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1110 NULL,
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1111 NULL,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1112 sizeof(PidginWebView),
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1113 0,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1114 (GInstanceInitFunc)pidgin_webview_init,
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1115 NULL
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1116 };
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1117 mview_type = g_type_register_static(webkit_web_view_get_type(),
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1118 "PidginWebView", &mview_info, 0);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1119 }
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1120 return mview_type;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1121 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1122
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1123 /*****************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1124 * Public API functions
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1125 *****************************************************************************/
32793
db876e8e41ac Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32791
diff changeset
1126
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1127 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1128 pidgin_webview_quote_js_string(const char *text)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1129 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1130 GString *str = g_string_new("\"");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1131 const char *cur = text;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1132
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1133 while (cur && *cur) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1134 switch (*cur) {
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1135 case '\\':
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1136 g_string_append(str, "\\\\");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1137 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1138 case '\"':
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1139 g_string_append(str, "\\\"");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1140 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1141 case '\r':
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1142 g_string_append(str, "<br/>");
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1143 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1144 case '\n':
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1145 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1146 default:
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1147 g_string_append_c(str, *cur);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1148 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1149 cur++;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1150 }
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1151
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1152 g_string_append_c(str, '"');
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1153
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1154 return g_string_free(str, FALSE);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1155 }
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1156
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1157 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1158 pidgin_webview_safe_execute_script(PidginWebView *webview, const char *script)
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1159 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1160 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1161
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1162 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1163
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1164 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1165 g_queue_push_tail(priv->load_queue, GINT_TO_POINTER(LOAD_JS));
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1166 g_queue_push_tail(priv->load_queue, g_strdup(script));
33224
4bb64c5ef111 Ensure queue processing function is only added once.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33223
diff changeset
1167 if (!priv->is_loading && priv->loader == 0)
4bb64c5ef111 Ensure queue processing function is only added once.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33223
diff changeset
1168 priv->loader = g_idle_add((GSourceFunc)process_load_queue, webview);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1169 }
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1170
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1171 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1172 pidgin_webview_load_html_string(PidginWebView *webview, const char *html)
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1173 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1174 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1175
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1176 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), html, NULL, NULL,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1177 "file:///");
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1178 }
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1179
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1180 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1181 pidgin_webview_load_html_string_with_selection(PidginWebView *webview, const char *html)
33083
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1182 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1183 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1184
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1185 pidgin_webview_load_html_string(webview, html);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1186 pidgin_webview_safe_execute_script(webview,
33083
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1187 "var s = window.getSelection();"
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1188 "var r = document.createRange();"
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1189 "var n = document.getElementById('caret');"
33084
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1190 "r.selectNodeContents(n);"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1191 "var f = r.extractContents();"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1192 "r.selectNode(n);"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1193 "r.insertNode(f);"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1194 "n.parentNode.removeChild(n);"
33083
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1195 "s.removeAllRanges();"
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1196 "s.addRange(r);");
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1197 }
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1198
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1199 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1200 pidgin_webview_append_html(PidginWebView *webview, const char *html)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1201 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1202 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1203
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1204 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1205
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1206 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1207 g_queue_push_tail(priv->load_queue, GINT_TO_POINTER(LOAD_HTML));
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1208 g_queue_push_tail(priv->load_queue, g_strdup(html));
33224
4bb64c5ef111 Ensure queue processing function is only added once.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33223
diff changeset
1209 if (!priv->is_loading && priv->loader == 0)
4bb64c5ef111 Ensure queue processing function is only added once.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33223
diff changeset
1210 priv->loader = g_idle_add((GSourceFunc)process_load_queue, webview);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1211 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1212
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1213 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1214 pidgin_webview_set_vadjustment(PidginWebView *webview, GtkAdjustment *vadj)
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1215 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1216 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1217
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1218 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1219
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1220 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1221 priv->vadj = vadj;
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1222 }
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1223
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1224 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1225 pidgin_webview_scroll_to_end(PidginWebView *webview, gboolean smooth)
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1226 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1227 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1228
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1229 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1230
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1231 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1232 if (priv->scroll_time)
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1233 g_timer_destroy(priv->scroll_time);
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1234 if (priv->scroll_src)
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1235 g_source_remove(priv->scroll_src);
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1236 if (smooth) {
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1237 priv->scroll_time = g_timer_new();
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1238 priv->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, priv, NULL);
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1239 } else {
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1240 priv->scroll_time = NULL;
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1241 priv->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, priv, NULL);
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1242 }
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1243 }
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1244
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1245 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1246 pidgin_webview_set_autoscroll(PidginWebView *webview, gboolean scroll)
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1247 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1248 PidginWebViewPriv *priv;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1249
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1250 g_return_if_fail(webview != NULL);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1251
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1252 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1253 priv->autoscroll = scroll;
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1254 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1255
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1256 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1257 pidgin_webview_get_autoscroll(PidginWebView *webview)
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1258 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1259 PidginWebViewPriv *priv;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1260
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1261 g_return_val_if_fail(webview != NULL, FALSE);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1262
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1263 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1264 return priv->autoscroll;
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1265 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1266
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1267 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1268 pidgin_webview_page_up(PidginWebView *webview)
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1269 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1270 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1271 GtkAdjustment *vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1272 gdouble scroll_val;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1273
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1274 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1275
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1276 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1277 vadj = priv->vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1278 scroll_val = gtk_adjustment_get_value(vadj) - gtk_adjustment_get_page_size(vadj);
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1279 scroll_val = MAX(scroll_val, gtk_adjustment_get_lower(vadj));
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1280
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1281 gtk_adjustment_set_value(vadj, scroll_val);
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1282 }
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1283
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1284 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1285 pidgin_webview_page_down(PidginWebView *webview)
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1286 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1287 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1288 GtkAdjustment *vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1289 gdouble scroll_val;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1290 gdouble page_size;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1291
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1292 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1293
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1294 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1295 vadj = priv->vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1296 page_size = gtk_adjustment_get_page_size(vadj);
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1297 scroll_val = gtk_adjustment_get_value(vadj) + page_size;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1298 scroll_val = MIN(scroll_val, gtk_adjustment_get_upper(vadj) - page_size);
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1299
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1300 gtk_adjustment_set_value(vadj, scroll_val);
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1301 }
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1302
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1303 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1304 pidgin_webview_setup_entry(PidginWebView *webview, PurpleConnectionFlags flags)
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1305 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1306 PidginWebViewButtons buttons;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1307
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1308 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1309
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1310 if (flags & PURPLE_CONNECTION_FLAG_HTML) {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1311 gboolean bold, italic, underline, strike;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1312
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1313 buttons = PIDGIN_WEBVIEW_ALL;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1314
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1315 if (flags & PURPLE_CONNECTION_FLAG_NO_BGCOLOR)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1316 buttons &= ~PIDGIN_WEBVIEW_BACKCOLOR;
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1317 if (flags & PURPLE_CONNECTION_FLAG_NO_FONTSIZE)
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1318 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1319 buttons &= ~PIDGIN_WEBVIEW_GROW;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1320 buttons &= ~PIDGIN_WEBVIEW_SHRINK;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1321 }
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1322 if (flags & PURPLE_CONNECTION_FLAG_NO_URLDESC)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1323 buttons &= ~PIDGIN_WEBVIEW_LINKDESC;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1324
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1325 pidgin_webview_get_current_format(webview, &bold, &italic, &underline, &strike);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1326
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1327 pidgin_webview_set_format_functions(webview, PIDGIN_WEBVIEW_ALL);
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1328 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != bold)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1329 pidgin_webview_toggle_bold(webview);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1330
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1331 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != italic)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1332 pidgin_webview_toggle_italic(webview);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1333
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1334 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != underline)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1335 pidgin_webview_toggle_underline(webview);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1336
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1337 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike") != strike)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1338 pidgin_webview_toggle_strike(webview);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1339
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1340 pidgin_webview_toggle_fontface(webview,
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1341 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face"));
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1342
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1343 if (!(flags & PURPLE_CONNECTION_FLAG_NO_FONTSIZE))
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1344 {
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1345 int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size");
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1346
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1347 /* 3 is the default. */
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1348 if (size != 3)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1349 pidgin_webview_font_set_size(webview, size);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1350 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1351
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1352 pidgin_webview_toggle_forecolor(webview,
33025
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1353 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"));
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1354
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1355 if (!(flags & PURPLE_CONNECTION_FLAG_NO_BGCOLOR)) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1356 pidgin_webview_toggle_backcolor(webview,
33025
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1357 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"));
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1358 } else {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1359 pidgin_webview_toggle_backcolor(webview, "");
33025
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1360 }
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1361
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1362 if (flags & PURPLE_CONNECTION_FLAG_FORMATTING_WBFO)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1363 pidgin_webview_set_whole_buffer_formatting_only(webview, TRUE);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1364 else
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1365 pidgin_webview_set_whole_buffer_formatting_only(webview, FALSE);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1366 } else {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1367 buttons = PIDGIN_WEBVIEW_SMILEY | PIDGIN_WEBVIEW_IMAGE;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1368 webview_clear_formatting(webview);
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1369 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1370
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1371 if (flags & PURPLE_CONNECTION_FLAG_NO_IMAGES)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1372 buttons &= ~PIDGIN_WEBVIEW_IMAGE;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1373
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1374 if (flags & PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1375 buttons |= PIDGIN_WEBVIEW_CUSTOM_SMILEY;
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1376 else
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1377 buttons &= ~PIDGIN_WEBVIEW_CUSTOM_SMILEY;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1378
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1379 pidgin_webview_set_format_functions(webview, buttons);
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1380 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1381
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1382 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1383 pidgin_webview_set_spellcheck(PidginWebView *webview, gboolean enable)
33021
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1384 {
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1385 WebKitWebSettings *settings;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1386
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1387 g_return_if_fail(webview != NULL);
33021
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1388
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1389 settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webview));
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1390 g_object_set(G_OBJECT(settings), "enable-spell-checking", enable, NULL);
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1391 webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webview), settings);
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1392 }
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1393
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1394 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1395 pidgin_webview_set_whole_buffer_formatting_only(PidginWebView *webview, gboolean wbfo)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1396 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1397 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1398
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1399 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1400
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1401 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1402 priv->edit.wbfo = wbfo;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1403 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1404
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1405 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1406 pidgin_webview_set_format_functions(PidginWebView *webview, PidginWebViewButtons buttons)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1407 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1408 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1409 GObject *object;
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1410
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1411 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1412
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1413 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1414 object = g_object_ref(G_OBJECT(webview));
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1415 priv->format_functions = buttons;
32812
5be5c09c86de Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32811
diff changeset
1416 g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons);
5be5c09c86de Emit the allowed-formats-updated signal when the set_format_functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32811
diff changeset
1417 g_object_unref(object);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1418 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1419
33231
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1420 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1421 pidgin_webview_activate_anchor(WebKitDOMHTMLAnchorElement *link)
33231
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1422 {
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1423 WebKitDOMDocument *doc;
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1424 WebKitDOMEvent *event;
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1425
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1426 doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(link));
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1427 event = webkit_dom_document_create_event(doc, "MouseEvent", NULL);
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1428 webkit_dom_event_init_event(event, "click", TRUE, TRUE);
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1429 webkit_dom_node_dispatch_event(WEBKIT_DOM_NODE(link), event, NULL);
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1430 }
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1431
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1432 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1433 pidgin_webview_class_register_protocol(const char *name,
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1434 gboolean (*activate)(PidginWebView *webview, const char *uri),
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1435 gboolean (*context_menu)(PidginWebView *webview, WebKitDOMHTMLAnchorElement *link, GtkWidget *menu))
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1436 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1437 PidginWebViewClass *klass;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1438 PidginWebViewProtocol *proto;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1439
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1440 g_return_val_if_fail(name, FALSE);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1441
35506
4252b2882889 Fix some remaining GTK_* macros as Elliott noticed
Ankit Vani <a@nevitus.org>
parents: 35500
diff changeset
1442 klass = g_type_class_ref(PIDGIN_TYPE_WEBVIEW);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1443 g_return_val_if_fail(klass, FALSE);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1444
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1445 if ((proto = webview_find_protocol(name, TRUE))) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1446 if (activate) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1447 return FALSE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1448 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1449 klass->protocols = g_list_remove(klass->protocols, proto);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1450 g_free(proto->name);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1451 g_free(proto);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1452 return TRUE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1453 } else if (!activate) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1454 return FALSE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1455 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1456
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1457 proto = g_new0(PidginWebViewProtocol, 1);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1458 proto->name = g_strdup(name);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1459 proto->length = strlen(name);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1460 proto->activate = activate;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1461 proto->context_menu = context_menu;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1462 klass->protocols = g_list_prepend(klass->protocols, proto);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1463
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1464 return TRUE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1465 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1466
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1467 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1468 pidgin_webview_get_head_html(PidginWebView *webview)
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1469 {
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1470 WebKitDOMDocument *doc;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1471 WebKitDOMHTMLHeadElement *head;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1472 gchar *html;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1473
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1474 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1475
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1476 doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1477 head = webkit_dom_document_get_head(doc);
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1478 html = webkit_dom_html_element_get_inner_html(WEBKIT_DOM_HTML_ELEMENT(head));
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1479
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1480 return html;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1481 }
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1482
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1483 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1484 pidgin_webview_get_body_html(PidginWebView *webview)
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1485 {
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1486 WebKitDOMDocument *doc;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1487 WebKitDOMHTMLElement *body;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1488 gchar *html;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1489
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1490 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1491
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1492 doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1493 body = webkit_dom_document_get_body(doc);
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1494 html = webkit_dom_html_element_get_inner_html(body);
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1495
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1496 return html;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1497 }
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1498
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1499 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1500 pidgin_webview_get_body_text(PidginWebView *webview)
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1501 {
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1502 WebKitDOMDocument *doc;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1503 WebKitDOMHTMLElement *body;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1504 gchar *text;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1505
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1506 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1507
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1508 doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1509 body = webkit_dom_document_get_body(doc);
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1510 text = webkit_dom_html_element_get_inner_text(body);
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1511
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1512 return text;
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1513 }
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1514
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1515 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1516 pidgin_webview_get_selected_text(PidginWebView *webview)
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1517 {
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1518 WebKitDOMDocument *dom;
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1519 WebKitDOMDOMWindow *win;
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1520 WebKitDOMDOMSelection *sel;
33254
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1521 WebKitDOMRange *range = NULL;
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1522
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1523 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1524
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1525 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1526 win = webkit_dom_document_get_default_view(dom);
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1527 sel = webkit_dom_dom_window_get_selection(win);
33254
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1528 if (webkit_dom_dom_selection_get_range_count(sel))
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1529 range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1530
33254
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1531 if (range)
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1532 return webkit_dom_range_get_text(range);
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1533 else
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1534 return NULL;
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1535 }
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1536
35129
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1537 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1538 pidgin_webview_get_caret(PidginWebView *webview, WebKitDOMNode **container_ret,
35129
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1539 glong *pos_ret)
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1540 {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1541 WebKitDOMDocument *dom;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1542 WebKitDOMDOMWindow *win;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1543 WebKitDOMDOMSelection *sel;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1544 WebKitDOMRange *range = NULL;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1545 WebKitDOMNode *start_container, *end_container;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1546 glong start, end;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1547
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1548 g_return_if_fail(webview && container_ret && pos_ret);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1549
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1550 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1551 win = webkit_dom_document_get_default_view(dom);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1552 sel = webkit_dom_dom_window_get_selection(win);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1553 if (webkit_dom_dom_selection_get_range_count(sel))
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1554 range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1555
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1556 if (range) {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1557 start_container = webkit_dom_range_get_start_container(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1558 start = webkit_dom_range_get_start_offset(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1559 end_container = webkit_dom_range_get_end_container(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1560 end = webkit_dom_range_get_end_offset(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1561
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1562 if (start == end &&
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1563 webkit_dom_node_is_same_node(start_container, end_container)) {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1564
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1565 *container_ret = start_container;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1566 *pos_ret = start;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1567 return;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1568 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1569 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1570
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1571 *container_ret = NULL;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1572 *pos_ret = -1;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1573 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1574
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1575 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1576 pidgin_webview_set_caret(PidginWebView *webview, WebKitDOMNode *container, glong pos)
35129
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1577 {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1578 WebKitDOMDocument *dom;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1579 WebKitDOMDOMWindow *win;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1580 WebKitDOMDOMSelection *sel;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1581
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1582 g_return_if_fail(webview && container && pos >= 0);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1583
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1584 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1585 win = webkit_dom_document_get_default_view(dom);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1586 sel = webkit_dom_dom_window_get_selection(win);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1587
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1588 webkit_dom_dom_selection_set_position(sel, container, pos, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1589 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1590
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1591 PidginWebViewButtons
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1592 pidgin_webview_get_format_functions(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1593 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1594 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1595
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1596 g_return_val_if_fail(webview != NULL, 0);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1597
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1598 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1599 return priv->format_functions;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1600 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1601
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1602 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1603 pidgin_webview_get_current_format(PidginWebView *webview, gboolean *bold,
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1604 gboolean *italic, gboolean *underline,
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1605 gboolean *strike)
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1606 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1607 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1608
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1609 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1610
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1611 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1612
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1613 if (bold)
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1614 *bold = webkit_dom_document_query_command_state(dom, "bold");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1615 if (italic)
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1616 *italic = webkit_dom_document_query_command_state(dom, "italic");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1617 if (underline)
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1618 *underline = webkit_dom_document_query_command_state(dom, "underline");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1619 if (strike)
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1620 *strike = webkit_dom_document_query_command_state(dom, "strikethrough");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1621 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1622
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1623 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1624 pidgin_webview_get_current_fontface(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1625 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1626 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1627
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1628 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1629
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1630 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1631 return webkit_dom_document_query_command_value(dom, "fontName");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1632 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1633
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1634 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1635 pidgin_webview_get_current_forecolor(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1636 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1637 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1638
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1639 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1640
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1641 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1642 return webkit_dom_document_query_command_value(dom, "foreColor");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1643 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1644
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1645 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1646 pidgin_webview_get_current_backcolor(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1647 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1648 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1649
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1650 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1651
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1652 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1653 return webkit_dom_document_query_command_value(dom, "backColor");
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1654 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1655
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1656 gint
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1657 pidgin_webview_get_current_fontsize(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1658 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1659 WebKitDOMDocument *dom;
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1660 gchar *text;
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1661 gint size;
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1662
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1663 g_return_val_if_fail(webview != NULL, 0);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1664
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1665 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1666 text = webkit_dom_document_query_command_value(dom, "fontSize");
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1667 size = atoi(text);
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1668 g_free(text);
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1669
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1670 return size;
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1671 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1672
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1673 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1674 pidgin_webview_clear_formatting(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1675 {
32813
d1dc6f667a34 Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32812
diff changeset
1676 GObject *object;
d1dc6f667a34 Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32812
diff changeset
1677
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1678 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1679
32813
d1dc6f667a34 Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32812
diff changeset
1680 object = g_object_ref(G_OBJECT(webview));
d1dc6f667a34 Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32812
diff changeset
1681 g_signal_emit(object, signals[CLEAR_FORMAT], 0);
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1682 g_object_unref(object);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1683 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1684
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1685 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1686 pidgin_webview_toggle_bold(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1687 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1688 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1689 emit_format_signal(webview, PIDGIN_WEBVIEW_BOLD);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1690 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1691
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1692 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1693 pidgin_webview_toggle_italic(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1694 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1695 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1696 emit_format_signal(webview, PIDGIN_WEBVIEW_ITALIC);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1697 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1698
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1699 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1700 pidgin_webview_toggle_underline(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1701 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1702 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1703 emit_format_signal(webview, PIDGIN_WEBVIEW_UNDERLINE);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1704 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1705
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1706 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1707 pidgin_webview_toggle_strike(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1708 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1709 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1710 emit_format_signal(webview, PIDGIN_WEBVIEW_STRIKE);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1711 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1712
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1713 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1714 pidgin_webview_toggle_forecolor(PidginWebView *webview, const char *color)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1715 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1716 g_return_val_if_fail(webview != NULL, FALSE);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1717
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
1718 do_formatting(webview, "foreColor", color);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1719 emit_format_signal(webview, PIDGIN_WEBVIEW_FORECOLOR);
32823
f179695f60cb Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32813
diff changeset
1720
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1721 return FALSE;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1722 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1723
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1724 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1725 pidgin_webview_toggle_backcolor(PidginWebView *webview, const char *color)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1726 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1727 g_return_val_if_fail(webview != NULL, FALSE);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1728
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
1729 do_formatting(webview, "backColor", color);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1730 emit_format_signal(webview, PIDGIN_WEBVIEW_BACKCOLOR);
32823
f179695f60cb Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32813
diff changeset
1731
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1732 return FALSE;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1733 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1734
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1735 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1736 pidgin_webview_toggle_fontface(PidginWebView *webview, const char *face)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1737 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1738 g_return_val_if_fail(webview != NULL, FALSE);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1739
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
1740 do_formatting(webview, "fontName", face);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1741 emit_format_signal(webview, PIDGIN_WEBVIEW_FACE);
32823
f179695f60cb Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32813
diff changeset
1742
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1743 return FALSE;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1744 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1745
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1746 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1747 pidgin_webview_font_set_size(PidginWebView *webview, gint size)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1748 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1749 char *tmp;
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1750
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1751 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1752
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1753 tmp = g_strdup_printf("%d", size);
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
1754 do_formatting(webview, "fontSize", tmp);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1755 emit_format_signal(webview, PIDGIN_WEBVIEW_SHRINK|PIDGIN_WEBVIEW_GROW);
32823
f179695f60cb Add some code for manipulating the WebView in edit-mode. Thanks to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32813
diff changeset
1756 g_free(tmp);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1757 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1758
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1759 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1760 pidgin_webview_font_shrink(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1761 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1762 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1763 emit_format_signal(webview, PIDGIN_WEBVIEW_SHRINK);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1764 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1765
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1766 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1767 pidgin_webview_font_grow(PidginWebView *webview)
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1768 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1769 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1770 emit_format_signal(webview, PIDGIN_WEBVIEW_GROW);
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1771 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1772
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1773 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1774 pidgin_webview_insert_hr(PidginWebView *webview)
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1775 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1776 PidginWebViewPriv *priv;
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1777 WebKitDOMDocument *dom;
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1778
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1779 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1780
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1781 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1782 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1783
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1784 priv->edit.block_changed = TRUE;
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1785 webkit_dom_document_exec_command(dom, "insertHorizontalRule", FALSE, "");
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1786 priv->edit.block_changed = FALSE;
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1787 }
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
1788
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1789 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1790 pidgin_webview_insert_link(PidginWebView *webview, const char *url, const char *desc)
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1791 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1792 PidginWebViewPriv *priv;
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1793 WebKitDOMDocument *dom;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1794 char *link;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1795
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1796 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1797
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1798 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1799 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
33016
509c717fcf6e The URL probably needs to be quoted.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33014
diff changeset
1800 link = g_strdup_printf("<a href='%s'>%s</a>", url, desc ? desc : url);
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1801
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1802 priv->edit.block_changed = TRUE;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1803 webkit_dom_document_exec_command(dom, "insertHTML", FALSE, link);
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1804 priv->edit.block_changed = FALSE;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1805 g_free(link);
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1806 }
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
1807
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1808 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1809 pidgin_webview_insert_image(PidginWebView *webview, int id)
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1810 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1811 PidginWebViewPriv *priv;
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1812 WebKitDOMDocument *dom;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1813 char *img;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1814
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1815 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1816
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1817 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1818 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1819 img = g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'/>",
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1820 id);
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1821
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1822 priv->edit.block_changed = TRUE;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1823 webkit_dom_document_exec_command(dom, "insertHTML", FALSE, img);
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1824 priv->edit.block_changed = FALSE;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1825 g_free(img);
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1826 }
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
1827
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1828 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1829 pidgin_webview_set_toolbar(PidginWebView *webview, GtkWidget *toolbar)
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1830 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1831 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1832
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1833 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1834
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1835 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1836 priv->toolbar = PIDGIN_WEBVIEWTOOLBAR(toolbar);
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1837 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1838
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1839 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1840 pidgin_webview_show_toolbar(PidginWebView *webview)
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1841 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1842 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1843
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1844 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1845
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1846 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1847 g_return_if_fail(priv->toolbar != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1848
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1849 gtk_widget_show(GTK_WIDGET(priv->toolbar));
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1850 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1851
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1852 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1853 pidgin_webview_hide_toolbar(PidginWebView *webview)
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1854 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1855 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1856
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1857 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1858
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1859 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1860 g_return_if_fail(priv->toolbar != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1861
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1862 gtk_widget_hide(GTK_WIDGET(priv->toolbar));
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1863 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1864
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1865 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1866 pidgin_webview_activate_toolbar(PidginWebView *webview, PidginWebViewAction action)
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1867 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1868 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1869
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1870 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1871
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1872 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1873 g_return_if_fail(priv->toolbar != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1874
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1875 pidgin_webviewtoolbar_activate(priv->toolbar, action);
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1876 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
1877
35713
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1878 void
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1879 pidgin_webview_switch_active_conversation(PidginWebView *webview,
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1880 PurpleConversation *conv)
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1881 {
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1882 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1883
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1884 g_return_if_fail(priv != NULL);
35716
80bedd712883 Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35714
diff changeset
1885 if (priv->toolbar == NULL)
80bedd712883 Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35714
diff changeset
1886 return;
35713
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1887
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1888 pidgin_webviewtoolbar_switch_active_conversation(priv->toolbar, conv);
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
1889 }

mercurial