pidgin/gtkwebview.c

Tue, 03 May 2016 14:04:15 -0400

author
Youness Alaoui <kakaroto@kakaroto.homelinux.net>
date
Tue, 03 May 2016 14:04:15 -0400
changeset 37759
35e8677c6ce5
parent 37240
d70b97846c13
child 37879
38eebb7c9019
permissions
-rw-r--r--

oscar: Prepend server option instead of appending it

This allows server/port to be together and appear on top of the
advanced settings instead of having port on top and server at the bottom

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"
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
26 #include "image-store.h"
36060
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
27 #include "marshallers.h"
32791
a2dc8d3ee1b8 Use internal.h for less (conditional) #includes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32774
diff changeset
28 #include "pidgin.h"
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
29 #include "pidginstock.h"
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
30
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
31 #include <gdk/gdkkeysyms.h>
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
32 #ifdef USE_ENCHANT
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
33 #include <enchant.h>
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
34 #endif
35194
9a0203562da5 pidgin: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents: 35129
diff changeset
35
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
36 #include "gtkutils.h"
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
37 #include "gtksmiley-manager.h"
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
38 #include "gtkwebview.h"
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
39 #include "gtkwebviewtoolbar.h"
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
40
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
41 #include "gtkinternal.h"
33170
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33167
diff changeset
42 #include "gtk3compat.h"
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33167
diff changeset
43
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
44 #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
45 #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
46 #define SCROLL_DELAY 33 /* milliseconds */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
47 #define PIDGIN_WEBVIEW_MAX_PROCESS_TIME 100000 /* microseconds */
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
48
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
49 #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
50 (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
51
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
52 enum {
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
53 LOAD_HTML,
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
54 LOAD_JS
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
55 };
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
56
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
57 enum {
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
58 BUTTONS_UPDATE,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
59 TOGGLE_FORMAT,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
60 CLEAR_FORMAT,
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
61 UPDATE_FORMAT,
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
62 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
63 HTML_APPENDED,
36060
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
64 INSERT_IMAGE,
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
65 LAST_SIGNAL
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
66 };
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
67 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
68
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
69 /******************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
70 * Structs
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
71 *****************************************************************************/
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
72
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
73 typedef struct {
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
74 WebKitWebInspector *inspector;
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
75 WebKitDOMNode *node;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
76 } PidginWebViewInspectData;
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
77
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
78 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
79 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
80 gunichar ch;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
81 } 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
82
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
83 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
84 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
85 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
86 } GtkUnicodeMenuEntry;
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
87
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
88 typedef struct {
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
89 char *name;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
90 int length;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
91
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
92 gboolean (*activate)(PidginWebView *webview, const char *uri);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
93 gboolean (*context_menu)(PidginWebView *webview, WebKitDOMHTMLAnchorElement *link, GtkWidget *menu);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
94 } PidginWebViewProtocol;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
95
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
96 typedef struct _PidginWebViewPriv {
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
97 /* 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
98 gboolean is_loading;
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
99 GQueue *load_queue;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
100 guint loader;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
101
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
102 /* Scroll adjustments */
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
103 GtkAdjustment *vadj;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
104 gboolean autoscroll;
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
105 guint scroll_src;
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
106 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
107
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
108 /* Format options */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
109 PidginWebViewButtons format_functions;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
110 PidginWebViewToolbar *toolbar;
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
111 struct {
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
112 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
113 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
114 } edit;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
115
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
116 /* WebKit inspector */
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
117 WebKitWebView *inspector_view;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
118 GtkWindow *inspector_win;
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
119
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
120 /* helper scripts */
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
121 gboolean refresh_spell_installed;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
122 } PidginWebViewPriv;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
123
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
124 /******************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
125 * Globals
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
126 *****************************************************************************/
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
127
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
128 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
129
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
130 static GRegex *smileys_re = NULL;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
131 static GRegex *empty_html_re = NULL;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
132
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
133 /* Resources cache.
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
134 *
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
135 * It's global, because gtkwebkit calls "resource-load-finished" only once
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
136 * for each static resource.
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
137 */
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
138 static GHashTable *globally_loaded_images = NULL;
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
139 guint globally_loaded_images_refcnt = 0;
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
140
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
141 static GList *spellcheck_languages = NULL;
35671
d1cc97d667a2 Box PidginSmiley and PidginWebViewSmiley
Ankit Vani <a@nevitus.org>
parents: 35648
diff changeset
142
33256
2bf06f291ff7 Add some smiley stuff to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33254
diff changeset
143 /******************************************************************************
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
144 * Helpers
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
145 *****************************************************************************/
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
146
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
147 static void
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
148 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
149 WebKitWebFrame *frame,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
150 WebKitWebResource *resource,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
151 WebKitNetworkRequest *request,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
152 WebKitNetworkResponse *response,
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
153 gpointer user_data)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
154 {
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
155 const gchar *uri;
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
156 PurpleImage *img = NULL;
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
157 const gchar *path;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
158
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
159 uri = webkit_network_request_get_uri(request);
35831
86b7a6d3d267 PurpleImage: use purple_image_store_get_from_uri where possible
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35830
diff changeset
160 if ((img = purple_image_store_get_from_uri(uri)) != NULL) {
86b7a6d3d267 PurpleImage: use purple_image_store_get_from_uri where possible
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35830
diff changeset
161 /* noop */
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
162 } else if (purple_str_has_prefix(uri, PURPLE_IMAGE_STORE_STOCK_PROTOCOL)) {
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
163 gchar *p_uri, *found;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
164 const gchar *domain, *stock_name;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
165
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
166 uri += sizeof(PURPLE_IMAGE_STORE_STOCK_PROTOCOL) - 1;
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
167
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
168 p_uri = g_strdup(uri);
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
169 found = strchr(p_uri, '/');
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
170 if (!found) {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
171 purple_debug_warning("webview", "Invalid purple stock "
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
172 "image uri: %s", uri);
37240
d70b97846c13 Fix a memory leak on a temporary copy of the uri
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37219
diff changeset
173 g_free(p_uri);
34490
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
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
177 found[0] = '\0';
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
178 domain = p_uri;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
179 stock_name = found + 1;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
180
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
181 if (g_strcmp0(domain, "e2ee") == 0) {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
182 img = _pidgin_e2ee_stock_icon_get(stock_name);
37240
d70b97846c13 Fix a memory leak on a temporary copy of the uri
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37219
diff changeset
183 if (!img) {
d70b97846c13 Fix a memory leak on a temporary copy of the uri
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37219
diff changeset
184 g_free(p_uri);
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
185 return;
37240
d70b97846c13 Fix a memory leak on a temporary copy of the uri
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37219
diff changeset
186 }
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
187 } else {
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
188 purple_debug_warning("webview", "Invalid purple stock "
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
189 "image domain: %s", domain);
37240
d70b97846c13 Fix a memory leak on a temporary copy of the uri
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37219
diff changeset
190
d70b97846c13 Fix a memory leak on a temporary copy of the uri
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37219
diff changeset
191 g_free(p_uri);
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
192 return;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
193 }
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
194 } else
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
195 return;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
196
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
197 if (img != NULL) {
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
198 path = purple_image_get_path(img);
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
199 if (path) {
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
200 gchar *uri = g_filename_to_uri(path, NULL, NULL);
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
201 webkit_network_request_set_uri(request, uri);
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
202 g_free(uri);
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
203 } else {
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
204 gchar *b64, *src;
34490
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
205 const gchar *type;
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
206
4825e8b34919 E2EE: implement PURPLE_STOCK_IMAGE_PROTOCOL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
207 b64 = purple_base64_encode(
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
208 purple_image_get_data(img),
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
209 purple_image_get_size(img));
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
210 type = purple_image_get_mimetype(img);
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
211 src = g_strdup_printf("data:%s;base64,%s", type, b64);
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
212 g_free(b64);
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
213 webkit_network_request_set_uri(request, src);
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
214 g_free(src);
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
215 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
216 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
217 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
218
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
219 static void
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
220 webview_resource_loaded(WebKitWebView *web_view, WebKitWebFrame *web_frame,
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
221 WebKitWebResource *web_resource, gpointer user_data)
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
222 {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
223 const gchar *uri;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
224 GString *data;
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
225 PurpleImage *image = NULL;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
226
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
227 if (!purple_str_has_caseprefix(
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
228 webkit_web_resource_get_mime_type(web_resource), "image/"))
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
229 {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
230 return;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
231 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
232
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
233 uri = webkit_web_resource_get_uri(web_resource);
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
234 if (g_hash_table_lookup(globally_loaded_images, uri))
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
235 return;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
236
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
237 data = webkit_web_resource_get_data(web_resource);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
238 if (data->len == 0)
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
239 return;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
240
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
241 image = purple_image_store_get_from_uri(uri);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
242 if (image) {
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
243 g_object_ref(image);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
244 } else {
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
245 image = purple_image_new_from_data(
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
246 g_memdup(data->str, data->len), data->len);
35841
56e1ef289cbb Webkit: preserve file names for inline images and smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
247 if (purple_str_has_prefix(uri, "file:"))
56e1ef289cbb Webkit: preserve file names for inline images and smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35831
diff changeset
248 purple_image_set_friendly_filename(image, uri);
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
249 g_return_if_fail(image != NULL);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
250 }
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
251
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
252 g_hash_table_insert(globally_loaded_images, g_strdup(uri), image);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
253 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
254
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
255 static PurpleImage *
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
256 webview_resource_get_loaded(WebKitWebView *web_view, const gchar *uri)
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
257 {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
258 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(web_view);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
259
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
260 g_return_val_if_fail(priv != NULL, NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
261
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
262 return g_hash_table_lookup(globally_loaded_images, uri);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
263 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
264
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
265 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
266 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
267 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
268 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
269 int type;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
270 char *str;
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
271 WebKitDOMDocument *doc;
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
272 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
273 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
274 WebKitDOMRange *range;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
275 gboolean require_scroll = FALSE;
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
276
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
277 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
278 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
279
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
280 switch (type) {
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
281 case LOAD_HTML:
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
282 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
283 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
284 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
285
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
286 if (priv->autoscroll) {
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
287 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
288 >= (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
289 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
290 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
291
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
292 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
293 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
294
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
295 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
296 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
297 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
298 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
299 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
300 NULL);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
301 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
302 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
303 NULL);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
304 } else {
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
305 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
306 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
307 NULL);
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
308 }
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
309
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
310 if (require_scroll) {
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
311 if (start)
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
312 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
313 TRUE);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
314 else
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
315 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
316 TRUE);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
317 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
318
33241
d5a07f1ea70b Add a signal for when HTML is appended to a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33233
diff changeset
319 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
320
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
321 break;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
322
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
323 case LOAD_JS:
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
324 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
325 break;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
326
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
327 default:
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
328 purple_debug_error("webview",
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
329 "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
330 break;
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
331 }
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
332
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
333 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
334 }
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
335
33535
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
336 static gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
337 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
338 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
339 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
340 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
341
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
342 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
343 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
344 return FALSE;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
345 }
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
346 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
347 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
348 return FALSE;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
349 }
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
350
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
351 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
352 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
353 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
354 if (g_get_monotonic_time() - start_time >
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
355 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
356 break;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
357 }
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
358
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
359 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
360 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
361 return FALSE;
e03ae42cf793 Faster webkit webview - process elements from queue until timeout is hit
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33500
diff changeset
362 }
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
363 return TRUE;
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
364 }
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
365
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
366 static void
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
367 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
368 gpointer userdata)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
369 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
370 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
371
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
372 /* 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
373 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
374 }
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
375
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
376 static void
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
377 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
378 gpointer userdata)
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
379 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
380 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
381
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
382 priv->is_loading = FALSE;
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
383 if (priv->loader == 0)
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
384 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
385 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
386
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
387 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
388 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
389 {
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
390 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
391 }
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
392
34464
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
393 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
394 webview_inspector_destroy(GtkWindow *window, PidginWebViewPriv *priv)
34464
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
395 {
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
396 g_return_if_fail(priv->inspector_win == window);
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
397
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
398 priv->inspector_win = NULL;
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
399 priv->inspector_view = NULL;
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
400 }
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
401
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
402 static WebKitWebView *
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
403 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
404 WebKitWebView *webview, gpointer _unused)
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
405 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
406 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
407
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
408 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
409 return priv->inspector_view;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
410
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
411 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
412 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
413 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
414
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
415 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
416 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
417 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
418
34464
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
419 g_signal_connect(priv->inspector_win, "destroy",
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
420 G_CALLBACK(webview_inspector_destroy), priv);
8755f8900cb4 Gtk webview inspector: fix a crash
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34308
diff changeset
421
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
422 return priv->inspector_view;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
423 }
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
424
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
425 static gboolean
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
426 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
427 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
428 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
429
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
430 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
431
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
432 return TRUE;
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
433 }
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
434
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
435 static PidginWebViewProtocol *
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
436 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
437 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
438 PidginWebViewClass *klass;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
439 GList *iter;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
440 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
441 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
442
35506
4252b2882889 Fix some remaining GTK_* macros as Elliott noticed
Ankit Vani <a@nevitus.org>
parents: 35500
diff changeset
443 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
444 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
445 proto = iter->data;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
446 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
447 g_type_class_unref(klass);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
448 return proto;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
449 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
450 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
451
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
452 g_type_class_unref(klass);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
453 return NULL;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
454 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
455
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
456 static gboolean
33226
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
457 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
458 WebKitWebFrame *frame,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
459 WebKitNetworkRequest *request,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
460 WebKitWebNavigationAction *navigation_action,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
461 WebKitWebPolicyDecision *policy_decision,
ae332a3316c7 Give webview signal callback a more relevant name.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33225
diff changeset
462 gpointer userdata)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
463 {
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
464 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
465 WebKitWebNavigationReason reason;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
466
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
467 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
468 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
469
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
470 if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
471 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
472 if (proto) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
473 /* XXX: Do something with the return value? */
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
474 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
475 }
32800
67649fafdb51 If we handle a navigation request, then we should tell WebKit
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32799
diff changeset
476 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
477 } 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
478 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
479 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
480 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
481
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
482 return TRUE;
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
483 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
484
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
485 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
486 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
487 {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
488 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
489 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
490 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
491 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
492 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
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 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
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 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
497 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
498 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
499 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
500
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
501 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
502
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
503 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
504 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
505 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
506 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
507 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
508
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
509 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
510 }
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 /* 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
513 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
514 { 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
515 { 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
516 { 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
517 { 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
518 { 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
519 { 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
520 { 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
521 { 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
522 { 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
523 { 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
524 };
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
525
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
526 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
527 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
528 {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
529 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
530 gunichar ch = data->ch;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
531 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
532 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
533 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
534
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
535 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
536 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
537
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
538 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
539 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
540 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
541 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
542 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
543
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
544 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
545 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
546 {
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
547 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
548 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
549 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
550 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
551 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
552
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
553 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
554
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
555 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
556 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
557 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
558 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
559
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
560 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
561
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
562 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
563 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
564 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
565 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
566
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
567 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
568 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
569 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
570
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
571 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
572 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
573 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
574 (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
575 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
576 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
577 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
578
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
579 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
580
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
581 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
582 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
583
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
584 #ifdef USE_ENCHANT
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
585
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
586 static void
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
587 webview_refresh_spellcheck(WebKitWebView *webview)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
588 {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
589 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
590 static const gchar jsfunc[] =
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
591 "var pidgin_refresh_spellcheck = function() {"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
592 "var selection = window.getSelection();"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
593 "var originalSelection = selection.getRangeAt(0);"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
594 "for (var i = 0; i < 5; i++)"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
595 "selection.modify('move', 'backward', 'line');"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
596 "for (i = 0; i < 100; i++)"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
597 "selection.modify('move', 'forward', 'word');"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
598 "selection.removeAllRanges();"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
599 "selection.addRange(originalSelection);"
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
600 "};";
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
601
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
602 if (!priv->refresh_spell_installed) {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
603 priv->refresh_spell_installed = TRUE;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
604 webkit_web_view_execute_script(webview, jsfunc);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
605 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
606
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
607 webkit_web_view_execute_script(webview, "pidgin_refresh_spellcheck()");
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
608 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
609
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
610 static void
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
611 webview_lang_select(GtkMenuItem *item, const gchar *lang)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
612 {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
613 WebKitWebView *webview = g_object_get_data(G_OBJECT(item), "gtkwebview");
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
614 WebKitWebSettings *settings;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
615
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
616 g_return_if_fail(lang != NULL);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
617 g_return_if_fail(webview != NULL);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
618
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
619 settings = webkit_web_view_get_settings(webview);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
620 g_object_set(G_OBJECT(settings),
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
621 "spell-checking-languages", lang, NULL);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
622 webview_refresh_spellcheck(webview);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
623 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
624
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
625 static GtkWidget *
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
626 get_spelldict_menu(WebKitWebView *webview)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
627 {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
628 GtkWidget *menuitem;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
629 GtkWidget *menu;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
630 GList *it;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
631
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
632 if (spellcheck_languages == NULL)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
633 return NULL;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
634
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
635 menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Language"));
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
636 menu = gtk_menu_new();
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
637 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
638 for (it = spellcheck_languages; it; it = g_list_next(it)) {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
639 GtkWidget *item;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
640 const gchar *lang = it->data;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
641
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
642 /* we could convert lang id to name here */
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
643 item = gtk_menu_item_new_with_label(lang);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
644 g_object_set_data(G_OBJECT(item), "gtkwebview", webview);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
645 g_signal_connect(item, "activate",
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
646 G_CALLBACK(webview_lang_select), (gpointer)lang);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
647 gtk_widget_show(item);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
648 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
649 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
650
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
651 return menuitem;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
652 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
653
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
654 #else
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
655 static GtkWidget *
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
656 get_spelldict_menu(WebKitWebView *webview)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
657 {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
658 return NULL;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
659 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
660 #endif
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
661
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
662 static void
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
663 webview_image_saved(GtkWidget *dialog, gint response, gpointer _unused)
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
664 {
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
665 PurpleImage *image;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
666 gchar *filename;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
667
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
668 if (response != GTK_RESPONSE_ACCEPT) {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
669 gtk_widget_destroy(dialog);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
670 return;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
671 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
672
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
673 image = g_object_get_data(G_OBJECT(dialog), "pidgin-gtkwebview-image");
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
674 g_return_if_fail(image != NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
675
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
676 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
677 g_return_if_fail(filename != NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
678 g_return_if_fail(filename[0] != '\0');
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
679
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
680 if (!purple_image_save(image, filename)) {
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
681 purple_debug_error("gtkwebview", "Failed saving image");
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
682 /* TODO: we should display a notification here */
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
683 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
684
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
685 g_free(filename);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
686 gtk_widget_destroy(dialog);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
687 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
688
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
689 static void
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
690 webview_image_save(GtkWidget *item, WebKitDOMHTMLImageElement *image_node)
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
691 {
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
692 const gchar *src;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
693 WebKitWebView *webview;
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
694 PurpleImage *image;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
695 GtkFileChooserDialog *dialog;
35829
268931512478 imgstore: unref oscar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35814
diff changeset
696 const gchar *filename;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
697 GtkWidget *parent;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
698
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
699 webview = g_object_get_data(G_OBJECT(image_node), "pidgin-gtkwebview");
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
700 g_return_if_fail(webview != NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
701
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
702 src = webkit_dom_html_image_element_get_src(image_node); /* XXX: a leak or not? */
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
703 image = webview_resource_get_loaded(webview, src);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
704 g_return_if_fail(image != NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
705
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
706 parent = gtk_widget_get_ancestor(item, GTK_TYPE_WINDOW);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
707 dialog = GTK_FILE_CHOOSER_DIALOG(gtk_file_chooser_dialog_new(
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
708 _("Save Image"),
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
709 parent ? GTK_WINDOW(parent) : NULL,
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
710 GTK_FILE_CHOOSER_ACTION_SAVE,
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
711 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
712 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
713 NULL));
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
714 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
715 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
716
35829
268931512478 imgstore: unref oscar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35814
diff changeset
717 filename = purple_image_get_friendly_filename(image);
268931512478 imgstore: unref oscar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35814
diff changeset
718 g_warn_if_fail(filename != NULL);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
719 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
720
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
721 g_signal_connect(G_OBJECT(dialog), "response",
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
722 G_CALLBACK(webview_image_saved), NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
723
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
724 g_object_ref(image);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
725 g_object_set_data_full(G_OBJECT(dialog), "pidgin-gtkwebview-image",
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
726 image, g_object_unref);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
727
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
728 gtk_widget_show(GTK_WIDGET(dialog));
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
729 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
730
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
731 static void
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
732 webview_image_add_smiley(GtkWidget *item, WebKitDOMHTMLImageElement *image_node)
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
733 {
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
734 const gchar *src;
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
735 WebKitWebView *webview;
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
736 PurpleImage *image;
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
737
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
738 src = webkit_dom_html_image_element_get_src(image_node);
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
739 webview = g_object_get_data(G_OBJECT(image_node), "pidgin-gtkwebview");
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
740 g_return_if_fail(webview != NULL);
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
741
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
742 image = webview_resource_get_loaded(webview, src);
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
743 g_return_if_fail(image != NULL);
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
744
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
745 pidgin_smiley_manager_add(image,
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
746 webkit_dom_html_image_element_get_alt(image_node));
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
747 }
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
748
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
749 static void
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
750 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
751 WebKitDOMNode *node, const char *uri)
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
752 {
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
753 GtkWidget *menu;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
754 GtkWidget *cut, *copy, *paste, *delete, *select;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
755 gboolean show_clipboard = TRUE;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
756 WebKitDOMHTMLImageElement *image_node = NULL;
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
757
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
758 menu = gtk_menu_new();
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
759 g_signal_connect(menu, "selection-done",
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
760 G_CALLBACK(gtk_widget_destroy), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
761
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
762 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
763 PidginWebViewProtocol *proto = NULL;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
764 GList *children;
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
765 WebKitDOMNode *link_node = node;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
766
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
767 while (link_node && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link_node)) {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
768 link_node = webkit_dom_node_get_parent_node(node);
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
769 }
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
770
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
771 if (uri && link_node)
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
772 proto = webview_find_protocol(uri, FALSE);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
773
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
774 if (proto && proto->context_menu) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
775 proto->context_menu(PIDGIN_WEBVIEW(webview),
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
776 WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link_node), menu);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
777 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
778
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
779 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
780 if (!children) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
781 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
782 gtk_widget_show(item);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
783 gtk_widget_set_sensitive(item, FALSE);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
784 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
785 } else {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
786 g_list_free(children);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
787 }
33232
a572083f80ef Register protocols with GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33231
diff changeset
788 gtk_widget_show_all(menu);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
789
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
790 show_clipboard = FALSE;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
791 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
792
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
793 if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
794 WebKitDOMNode *_image_node = node;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
795
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
796 while (_image_node && !WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT(_image_node)) {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
797 _image_node = webkit_dom_node_get_parent_node(_image_node);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
798 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
799 if (_image_node)
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
800 image_node = WEBKIT_DOM_HTML_IMAGE_ELEMENT(_image_node);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
801 /* don't do it on our theme smileys */
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
802 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
803 if (image_node && webkit_dom_html_image_element_get_complete(image_node)) {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
804 GtkWidget *menu_item;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
805 int width, height;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
806
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
807 width = webkit_dom_html_image_element_get_width(image_node);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
808 height = webkit_dom_html_image_element_get_height(image_node);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
809
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
810 /* XXX */
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
811 g_object_set_data(G_OBJECT(image_node), "pidgin-gtkwebview", webview);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
812
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
813 menu_item = gtk_image_menu_item_new_with_mnemonic(
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
814 _("_Save Image..."));
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
815 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
816 gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU));
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
817 g_signal_connect_object(G_OBJECT(menu_item), "activate",
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
818 G_CALLBACK(webview_image_save), image_node, 0);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
819 gtk_widget_show(menu_item);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
820 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
821
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
822 /* TODO: check, if it's not *our* custom smiley (use css) */
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
823 if (width <= 96 && height <= 96) {
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
824 menu_item = gtk_image_menu_item_new_with_mnemonic(
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
825 _("_Add Custom Smiley..."));
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
826 gtk_image_menu_item_set_image(
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
827 GTK_IMAGE_MENU_ITEM(menu_item),
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
828 gtk_image_new_from_stock(GTK_STOCK_ADD,
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
829 GTK_ICON_SIZE_MENU));
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
830 g_signal_connect_object(G_OBJECT(menu_item), "activate",
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
831 G_CALLBACK(webview_image_add_smiley),
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
832 image_node, 0);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
833 gtk_widget_show(menu_item);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
834 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
835 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
836
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
837 show_clipboard = FALSE;
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
838 }
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
839
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
840 if (show_clipboard) {
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
841 /* 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
842 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
843 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
844 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
845 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
846 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
847
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
848 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
849 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
850 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
851 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
852 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
853
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
854 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
855 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
856 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
857 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
858 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
859
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
860 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
861 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
862 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
863 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
864 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
865
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
866 pidgin_separator(menu);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
867
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
868 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
869 GTK_STOCK_SELECT_ALL,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
870 NULL, NULL, 0, 0, NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
871 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
872 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
873 webview);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
874
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
875 gtk_widget_set_sensitive(cut,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
876 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
877 gtk_widget_set_sensitive(copy,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
878 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
879 gtk_widget_set_sensitive(paste,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
880 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
881 gtk_widget_set_sensitive(delete,
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
882 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
883 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
884
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
885 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
886 "/webview/inspector_enabled"))
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
887 {
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
888 WebKitWebSettings *settings;
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
889 GtkWidget *inspect;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
890 PidginWebViewInspectData *data;
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
891
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
892 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
893 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
894
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
895 data = g_new0(PidginWebViewInspectData, 1);
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
896 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
897 data->node = node;
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
898
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
899 pidgin_separator(menu);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
900
35785
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
901 inspect = pidgin_new_item_from_stock(menu, _("Inspect _Element"),
65ced7f8beaa Fix regression: saving small WebView images as a custom smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35784
diff changeset
902 PIDGIN_STOCK_DEBUG, NULL, NULL, 0, 0, NULL);
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
903 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
904 G_CALLBACK(webview_inspector_inspect_element),
33248
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
905 data, (GClosureNotify)g_free, 0);
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
906 }
565884eb4354 Restore "Inspect Element" menu item.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
907
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
908 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
909 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
910 GtkWidget *unicode = get_unicode_menu(webview);
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
911 GtkWidget *spelldict = get_spelldict_menu(webview);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
912
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
913 if (im || unicode || spelldict)
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
914 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
915
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
916 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
917 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
918 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
919 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
920
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
921 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
922 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
923 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
924 }
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
925
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
926 if (spelldict) {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
927 gtk_menu_shell_append(GTK_MENU_SHELL(menu), spelldict);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
928 gtk_widget_show(spelldict);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
929 }
33262
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
930 }
ec6997a4258c Copy the input-method and unicode menus from a regular WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33256
diff changeset
931
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
932 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
933
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
934 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
935 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
936 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
937
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
938 static gboolean
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
939 webview_popup_menu(WebKitWebView *webview)
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
940 {
33250
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
941 WebKitDOMDocument *doc;
35913
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
942 WebKitDOMNode *node = NULL;
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
943 int context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
944 char *uri = NULL;
33250
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
945
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
946 doc = webkit_web_view_get_dom_document(webview);
35913
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
947
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
948 /* it's unlikely, at least for webkit 1.x */
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
949 if (WEBKIT_DOM_IS_HTML_DOCUMENT(doc)) {
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
950 WebKitDOMElement *active;
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
951 WebKitDOMElement *link;
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
952 active = webkit_dom_html_document_get_active_element(
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
953 WEBKIT_DOM_HTML_DOCUMENT(doc));
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
954
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
955 link = active;
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
956 while (link && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link))
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
957 link = webkit_dom_node_get_parent_element(WEBKIT_DOM_NODE(link));
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
958 if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) {
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
959 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
960 uri = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link));
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
961 }
33250
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
962 }
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
963
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
964 do_popup_menu(webview, 0, gtk_get_current_event_time(),
35913
88714527fcb3 Fix invalid gobject cast
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35911
diff changeset
965 context, node, uri);
33250
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
966
84e141f1bfed Add some context when using the keyboard to open a popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33248
diff changeset
967 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
968
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
969 return TRUE;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
970 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
971
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
972 static gboolean
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
973 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
974 {
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
975 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
976 WebKitHitTestResult *hit;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
977 int context;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
978 WebKitDOMNode *node;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
979 char *uri;
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
980
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
981 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
982 g_object_get(G_OBJECT(hit),
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
983 "context", &context,
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
984 "inner-node", &node,
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
985 "link-uri", &uri,
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
986 NULL);
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
987
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
988 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
989 node, uri);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
990
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
991 g_free(uri);
33500
d6de39919ac3 Fix leak of the WebKitHitTestResult.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33265
diff changeset
992 g_object_unref(hit);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
993
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
994 return TRUE;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
995 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
996
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
997 return FALSE;
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
998 }
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
999
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1000 /*
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1001 * 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
1002 *
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1003 * @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
1004 */
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
1005 static gboolean
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1006 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
1007 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1008 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
1009 GtkAdjustment *adj;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1010 gdouble max_val;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1011 gdouble scroll_val;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1012
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1013 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
1014
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1015 adj = priv->vadj;
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
1016 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
1017 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
1018 ((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
1019
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1020 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
1021 || 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
1022 /* 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
1023 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
1024 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
1025 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
1026 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
1027 return FALSE;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1028 }
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
1029
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1030 /* 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
1031 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
1032 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
1033 }
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
1034
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1035 static gboolean
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1036 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
1037 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1038 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
1039 GtkAdjustment *adj = priv->vadj;
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
1040 gdouble max_val;
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
1041
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1042 if (adj) {
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
1043 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
1044 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
1045 }
32797
3fe407409ec2 Use accessor functions where available.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32796
diff changeset
1046
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1047 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
1048 return FALSE;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1049 }
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1050
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1051 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1052 emit_format_signal(PidginWebView *webview, PidginWebViewButtons buttons)
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1053 {
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1054 g_object_ref(webview);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1055 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
1056 g_object_unref(webview);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1057 }
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1058
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1059 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1060 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
1061 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1062 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
1063 WebKitDOMDocument *dom;
33022
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
1064 WebKitDOMDOMWindow *win;
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
1065 WebKitDOMDOMSelection *sel = NULL;
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1066 WebKitDOMRange *range = NULL;
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1067
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1068 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
1069
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1070 if (priv->edit.wbfo) {
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1071 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
1072 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
1073 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
1074 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
1075 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
1076 }
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1077
33010
aa658ddce5ec Don't emit the changed signal when modifying the webview ourselves.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33009
diff changeset
1078 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
1079 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
1080 priv->edit.block_changed = FALSE;
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1081
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1082 if (priv->edit.wbfo) {
33022
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
1083 if (range) {
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
1084 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
1085 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
1086 } else {
87c277f64c4e Avoid some asserts with WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33021
diff changeset
1087 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
1088 }
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1089 }
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1090 }
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1091
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1092 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1093 webview_font_shrink(PidginWebView *webview)
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1094 {
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1095 gint fontsize;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1096 char *tmp;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1097
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1098 fontsize = pidgin_webview_get_current_fontsize(webview);
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1099 fontsize = MAX(fontsize - 1, 1);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1100
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1101 tmp = g_strdup_printf("%d", fontsize);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1102 do_formatting(webview, "fontSize", tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1103 g_free(tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1104 }
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1105
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1106 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1107 webview_font_grow(PidginWebView *webview)
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1108 {
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1109 gint fontsize;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1110 char *tmp;
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1111
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1112 fontsize = pidgin_webview_get_current_fontsize(webview);
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1113 fontsize = MIN(fontsize + 1, MAX_FONT_SIZE);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1114
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1115 tmp = g_strdup_printf("%d", fontsize);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1116 do_formatting(webview, "fontSize", tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1117 g_free(tmp);
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1118 }
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1119
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1120 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1121 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
1122 {
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1123 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
1124 return;
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1125
33009
364b314b125a Clear formatting should also obey WBFO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33008
diff changeset
1126 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
1127 do_formatting(webview, "unlink", "");
03c013f8990c Remove links and background colours on format-clear.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33018
diff changeset
1128 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
1129 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1130
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1131 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1132 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
1133 {
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1134 /* 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
1135 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
1136 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
1137
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1138 switch (buttons) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1139 case PIDGIN_WEBVIEW_BOLD:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1140 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
1141 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1142 case PIDGIN_WEBVIEW_ITALIC:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1143 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
1144 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1145 case PIDGIN_WEBVIEW_UNDERLINE:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1146 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
1147 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1148 case PIDGIN_WEBVIEW_STRIKE:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1149 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
1150 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1151 case PIDGIN_WEBVIEW_SHRINK:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1152 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
1153 break;
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1154 case PIDGIN_WEBVIEW_GROW:
33018
cfa94708af72 Emit formatting toggle signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33017
diff changeset
1155 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
1156 break;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1157 default:
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1158 break;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1159 }
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1160 }
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1161
33007
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1162 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1163 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
1164 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1165 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
1166 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
1167 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
1168 }
78b670090850 Add a changed signal shortcut for editable webview changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33006
diff changeset
1169
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1170 /******************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1171 * GObject Stuff
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1172 *****************************************************************************/
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1173
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1174 GtkWidget *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1175 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
1176 {
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1177 GtkWidget *result;
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1178 WebKitWebView *webview;
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1179 WebKitWebSettings *settings;
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1180
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1181 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
1182 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
1183 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
1184
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
1185 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
1186 #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
1187 /* 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
1188 * "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
1189 * 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
1190 * 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
1191 */
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
1192 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
1193 #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
1194 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
1195
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1196 if (editable) {
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1197 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
1198
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1199 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
1200 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
1201 }
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1202
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1203 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
1204 }
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
1205
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
1206 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1207 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
1208 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1209 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
1210
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1211 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
1212 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
1213
33227
2541e55ae19d Only remove source if non-zero.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33226
diff changeset
1214 if (priv->loader)
2541e55ae19d Only remove source if non-zero.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33226
diff changeset
1215 g_source_remove(priv->loader);
33112
f3236514cb26 Queue HTML appends to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33097
diff changeset
1216
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1217 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
1218 g_queue_pop_head(priv->load_queue);
1e257009ac10 Fix Pidgin clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35671
diff changeset
1219 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
1220 }
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1221 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
1222
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1223 if (--globally_loaded_images_refcnt == 0) {
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1224 g_assert(globally_loaded_images != NULL);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1225 g_hash_table_destroy(globally_loaded_images);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1226 globally_loaded_images = NULL;
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1227 }
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
1228
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1229 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
1230 }
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
1231
35648
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1232 enum {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1233 PROP_0,
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1234 PROP_EXPAND
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1235 };
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1236
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1237 static void
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1238 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
1239 GParamSpec *pspec)
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1240 {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1241 g_return_if_fail(PIDGIN_IS_WEBVIEW(object));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1242
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1243 switch (prop_id) {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1244 case PROP_EXPAND:
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1245 purple_debug_misc("webview",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1246 "Ignored expand property (set to %d)",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1247 g_value_get_boolean(value));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1248 break;
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1249 default:
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1250 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1251 pspec);
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1252 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1253 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1254
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1255 static void
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1256 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
1257 {
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1258 g_return_if_fail(PIDGIN_IS_WEBVIEW(object));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1259
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1260 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1261 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1262
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1263 #ifdef USE_ENCHANT
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1264
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1265 static void
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1266 fill_spellcheck_dicts_cb(const gchar *lang_tag, const gchar *provider_name,
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1267 const gchar *provider_desc, const gchar *provider_file,
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1268 void *_unused)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1269 {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1270 gboolean is_dialect;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1271 GList *it;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1272
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1273 /* It's not super efficient, but even with large number of installed
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1274 * dictionaries (100?) it won't hurt us. */
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1275
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1276 is_dialect = (strchr(lang_tag, '_') != NULL);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1277
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1278 if (is_dialect) {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1279 for (it = spellcheck_languages; it; it = g_list_next(it)) {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1280 gchar *it_lang = it->data;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1281
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1282 if (purple_str_has_prefix(lang_tag, it_lang))
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1283 return;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1284 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1285 } else {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1286 GList *next;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1287 for (it = spellcheck_languages; it; it = next) {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1288 gchar *it_lang = it->data;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1289 next = g_list_next(it);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1290
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1291 if (!purple_str_has_prefix(it_lang, lang_tag))
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1292 continue;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1293
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1294 g_free(it_lang);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1295 spellcheck_languages =
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1296 g_list_delete_link(spellcheck_languages, it);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1297 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1298 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1299
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1300 spellcheck_languages = g_list_prepend(spellcheck_languages,
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1301 g_strdup(lang_tag));
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1302 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1303
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1304 static void
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1305 fill_spellcheck_dicts(void)
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1306 {
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1307 EnchantBroker *eb;
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1308
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1309 eb = enchant_broker_init();
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1310 enchant_broker_list_dicts(eb, fill_spellcheck_dicts_cb, NULL);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1311 enchant_broker_free(eb);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1312 spellcheck_languages = g_list_sort(spellcheck_languages,
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1313 (GCompareFunc)strcmp);
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1314 }
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1315
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1316 #endif
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1317
36060
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1318 static gboolean
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1319 pidgin_webview_insert_image_accu(GSignalInvocationHint *ihint,
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1320 GValue *return_accu, const GValue *handler_return, gpointer _unused)
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1321 {
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1322 gboolean cancel;
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1323
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1324 cancel = g_value_get_boolean(handler_return);
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1325 if (!cancel)
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1326 return FALSE;
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1327
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1328 g_value_set_boolean(return_accu, TRUE);
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1329 return TRUE;
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1330 }
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1331
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1332 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1333 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
1334 {
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1335 GObjectClass *gobject_class;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1336 GtkBindingSet *binding_set;
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1337
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1338 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
1339 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
1340
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1341 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
1342
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1343 /* Signals */
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1344
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1345 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
1346 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
1347 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1348 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
1349 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
1350 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
1351 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
1352 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
1353 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1354 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
1355 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
1356 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
1357 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
1358 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
1359 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1360 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
1361 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
1362 G_TYPE_NONE, 0);
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1363 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
1364 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
1365 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1366 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
1367 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
1368 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
1369 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
1370 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
1371 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1372 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
1373 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
1374 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
1375 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
1376 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
1377 G_SIGNAL_RUN_FIRST,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1378 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
1379 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
1380 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
1381 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
1382 NULL);
36060
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1383 signals[INSERT_IMAGE] = g_signal_new("insert-image",
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1384 G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST,
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1385 G_STRUCT_OFFSET(PidginWebViewClass, insert_image),
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1386 pidgin_webview_insert_image_accu, NULL,
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1387 purple_smarshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1,
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
1388 PURPLE_TYPE_IMAGE);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1389
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1390 /* Class Methods */
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1391
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1392 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
1393 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
1394
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1395 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
1396
34276
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1397 /* Key Bindings */
2b602f67f875 Make editable-ness a construct-only property of the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34274
diff changeset
1398
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1399 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
1400 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
1401 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1402 PIDGIN_WEBVIEW_BOLD);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1403 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
1404 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1405 PIDGIN_WEBVIEW_ITALIC);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1406 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
1407 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1408 PIDGIN_WEBVIEW_UNDERLINE);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1409 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
1410 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1411 PIDGIN_WEBVIEW_GROW);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1412 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
1413 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1414 PIDGIN_WEBVIEW_GROW);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1415 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
1416 "format-toggled", 1, G_TYPE_INT,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1417 PIDGIN_WEBVIEW_SHRINK);
32811
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1418
87c1f3bb5461 Add some formatting signals to webview from imhtml.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32810
diff changeset
1419 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
1420 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
1421 "format-cleared", 0);
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1422
35648
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1423 /* properties */
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1424
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1425 G_OBJECT_CLASS(klass)->set_property = pidgin_webview_set_property;
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1426 G_OBJECT_CLASS(klass)->get_property = pidgin_webview_get_property;
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1427
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1428 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
1429 /* webkitgtk for gtk2 doesn't seems to have this */
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1430 g_object_class_install_property(G_OBJECT_CLASS(klass),
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1431 PROP_EXPAND, g_param_spec_boolean("expand", "Expand Both",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1432 "Whether widget wants to expand in both directions",
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1433 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1434 }
6283b3708b03 Re-commit improved 3a61567
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35646
diff changeset
1435
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1436 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
1437 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/webview/inspector_enabled", FALSE);
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1438
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1439 g_return_if_fail(smileys_re == NULL);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1440 g_return_if_fail(empty_html_re == NULL);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1441 smileys_re = g_regex_new("<img[^>]* class=\"emoticon "
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1442 "[^\"^>]*\"[^>]*alt=\"([^\"^>]+)\"[^>]*>",
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1443 G_REGEX_DOTALL | G_REGEX_OPTIMIZE, 0, NULL);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1444 empty_html_re = g_regex_new("<(?!img)[^>]*>",
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1445 G_REGEX_DOTALL | G_REGEX_OPTIMIZE, 0, NULL);
35911
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1446
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1447 #ifdef USE_ENCHANT
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1448 fill_spellcheck_dicts();
e173a6f9a021 PidginWebView: spell checking dictionary selection
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35841
diff changeset
1449 #endif
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
1450 }
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
1451
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1452 static void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1453 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
1454 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1455 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
1456 WebKitWebInspector *inspector;
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1457
33222
868965128ec8 Combine HTML and JS loading queues.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33221
diff changeset
1458 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
1459
33228
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1460 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
1461 G_CALLBACK(webview_button_pressed), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1462
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1463 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
1464 G_CALLBACK(webview_popup_menu), NULL);
a5943b35eb77 Override the WebKitWebView default context menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33227
diff changeset
1465
33223
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1466 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
1467 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
1468
33223
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1469 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
1470 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
1471
33223
8bc668d886f4 Make some lines consistent with others.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33222
diff changeset
1472 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
1473 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
1474
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1475 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
1476 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
1477
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
1478 g_signal_connect(G_OBJECT(webview), "resource-load-finished",
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
1479 G_CALLBACK(webview_resource_loaded), NULL);
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
1480
34299
419c033e46b9 Enable WebKit inspector for all widgets, not only conversation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34276
diff changeset
1481 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
1482 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
1483 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
1484 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
1485 G_CALLBACK(webview_inspector_show), webview);
35784
247f6f06531f Fix regression: saving WebView images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35733
diff changeset
1486
35830
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1487 if (globally_loaded_images_refcnt++ == 0) {
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1488 g_assert(globally_loaded_images == NULL);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1489 globally_loaded_images = g_hash_table_new_full(g_str_hash,
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1490 g_str_equal, g_free, g_object_unref);
fb32647ef2f3 PurpleImage: better reference management
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35829
diff changeset
1491 }
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1492 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1493
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1494 GType
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1495 pidgin_webview_get_type(void)
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1496 {
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1497 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
1498 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
1499 static const GTypeInfo mview_info = {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1500 sizeof(PidginWebViewClass),
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1501 NULL,
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1502 NULL,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1503 (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
1504 NULL,
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1505 NULL,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1506 sizeof(PidginWebView),
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1507 0,
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1508 (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
1509 NULL
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1510 };
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1511 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
1512 "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
1513 }
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1514 return mview_type;
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1515 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1516
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1517 /*****************************************************************************
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1518 * Public API functions
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1519 *****************************************************************************/
32793
db876e8e41ac Avoid creating temporary files for images in a webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32791
diff changeset
1520
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1521 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1522 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
1523 {
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1524 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
1525 const char *cur = text;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1526
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1527 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
1528 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
1529 case '\\':
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1530 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
1531 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1532 case '\"':
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1533 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
1534 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1535 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
1536 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
1537 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1538 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
1539 break;
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1540 default:
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1541 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
1542 }
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1543 cur++;
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1544 }
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1545
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1546 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
1547
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1548 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
1549 }
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1550
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1551 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1552 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
1553 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1554 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1555
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1556 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1557
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1558 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
1559 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
1560 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
1561 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
1562 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
1563 }
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1564
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1565 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1566 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
1567 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1568 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1569
33054
177359654a3d Update the webview to use the new image sources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33030
diff changeset
1570 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
1571 "file:///");
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1572 }
32441
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1573
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1574 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1575 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
1576 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1577 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1578
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1579 pidgin_webview_load_html_string(webview, html);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1580 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
1581 "var s = window.getSelection();"
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1582 "var r = document.createRange();"
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1583 "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
1584 "r.selectNodeContents(n);"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1585 "var f = r.extractContents();"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1586 "r.selectNode(n);"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1587 "r.insertNode(f);"
1da63a04d506 Make sure the selection anchor is removed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33083
diff changeset
1588 "n.parentNode.removeChild(n);"
33083
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1589 "s.removeAllRanges();"
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1590 "s.addRange(r);");
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1591 }
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1592
e96acbe0e928 Move caret selection into GtkWebView code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33054
diff changeset
1593 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1594 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
1595 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1596 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1597
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1598 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1599
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1600 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
1601 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
1602 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
1603 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
1604 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
1605 }
8a015ca299f9 Apparently I missed these in my previous commit.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
diff changeset
1606
32796
34f384b0d75f Rearrange these files a bit to group common functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32794
diff changeset
1607 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1608 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
1609 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1610 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1611
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1612 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1613
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1614 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
1615 priv->vadj = vadj;
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1616 }
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1617
32513
9352b4c92d13 Clean up this WebKit stuff. Fix up broken merging, mark unfinished
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32506
diff changeset
1618 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1619 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
1620 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1621 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1622
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1623 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1624
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1625 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
1626 if (priv->scroll_time)
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1627 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
1628 if (priv->scroll_src)
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1629 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
1630 if (smooth) {
32500
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1631 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
1632 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
1633 } else {
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1634 priv->scroll_time = NULL;
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1635 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
1636 }
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1637 }
d8aa742c6288 webkit: Scroll to end when appending html.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32489
diff changeset
1638
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1639 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1640 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
1641 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1642 PidginWebViewPriv *priv;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1643
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1644 g_return_if_fail(webview != NULL);
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1645
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1646 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
1647 priv->autoscroll = scroll;
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1648 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1649
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1650 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1651 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
1652 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1653 PidginWebViewPriv *priv;
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1654
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1655 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
1656
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1657 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
1658 return priv->autoscroll;
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1659 }
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1660
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33241
diff changeset
1661 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1662 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
1663 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1664 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1665 GtkAdjustment *vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1666 gdouble scroll_val;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1667
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1668 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1669
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1670 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1671 vadj = priv->vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1672 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
1673 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
1674
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1675 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
1676 }
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1677
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1678 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1679 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
1680 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1681 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1682 GtkAdjustment *vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1683 gdouble scroll_val;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1684 gdouble page_size;
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1685
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1686 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1687
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1688 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1689 vadj = priv->vadj;
32772
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1690 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
1691 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
1692 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
1693
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1694 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
1695 }
9d79ccaeedfe Add page up/down for WebKit view.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32577
diff changeset
1696
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1697 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1698 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
1699 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1700 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
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);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1703
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1704 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
1705 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
1706
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1707 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
1708
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1709 if (flags & PURPLE_CONNECTION_FLAG_NO_BGCOLOR)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1710 buttons &= ~PIDGIN_WEBVIEW_BACKCOLOR;
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1711 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
1712 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1713 buttons &= ~PIDGIN_WEBVIEW_GROW;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1714 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
1715 }
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1716 if (flags & PURPLE_CONNECTION_FLAG_NO_URLDESC)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1717 buttons &= ~PIDGIN_WEBVIEW_LINKDESC;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1718
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1719 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
1720
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1721 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
1722 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
1723 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
1724
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1725 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
1726 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
1727
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1728 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
1729 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
1730
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
1731 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
1732 pidgin_webview_toggle_strike(webview);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1733
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1734 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
1735 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
1736
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1737 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
1738 {
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1739 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
1740
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1741 /* 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
1742 if (size != 3)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1743 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
1744 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1745
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1746 pidgin_webview_toggle_forecolor(webview,
33025
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1747 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
1748
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1749 if (!(flags & PURPLE_CONNECTION_FLAG_NO_BGCOLOR)) {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1750 pidgin_webview_toggle_backcolor(webview,
33025
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1751 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
1752 } else {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1753 pidgin_webview_toggle_backcolor(webview, "");
33025
74cd56966dbc This colour parsing seems unnecessary now.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33024
diff changeset
1754 }
32810
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1755
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1756 if (flags & PURPLE_CONNECTION_FLAG_FORMATTING_WBFO)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1757 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
1758 else
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1759 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
1760 } else {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1761 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
1762 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
1763 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1764
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1765 if (flags & PURPLE_CONNECTION_FLAG_NO_IMAGES)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1766 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
1767
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 33877
diff changeset
1768 if (flags & PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY)
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1769 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
1770 else
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1771 buttons &= ~PIDGIN_WEBVIEW_CUSTOM_SMILEY;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1772
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1773 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
1774 }
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1775
17dceb2423c2 Add a function for setting a WebView entry based on the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32805
diff changeset
1776 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1777 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
1778 {
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1779 WebKitWebSettings *settings;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1780
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1781 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
1782
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1783 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
1784 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
1785 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
1786 }
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1787
3dc4b2cdba7f Enable spell checking in an editable webview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33020
diff changeset
1788 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1789 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
1790 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1791 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1792
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1793 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1794
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1795 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
1796 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
1797 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1798
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1799 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1800 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
1801 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1802 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1803 GObject *object;
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1804
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1805 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1806
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1807 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1808 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
1809 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
1810 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
1811 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
1812 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
1813
33231
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1814 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1815 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
1816 {
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1817 WebKitDOMDocument *doc;
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1818 WebKitDOMEvent *event;
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1819
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1820 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
1821 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
1822 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
1823 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
1824 }
ab65d36fd975 Add a convenience function to activate a WebKit anchor element.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33229
diff changeset
1825
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1826 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1827 pidgin_webview_class_register_protocol(const char *name,
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1828 gboolean (*activate)(PidginWebView *webview, const char *uri),
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1829 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
1830 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1831 PidginWebViewClass *klass;
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1832 PidginWebViewProtocol *proto;
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1833
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1834 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
1835
35506
4252b2882889 Fix some remaining GTK_* macros as Elliott noticed
Ankit Vani <a@nevitus.org>
parents: 35500
diff changeset
1836 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
1837 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
1838
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1839 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
1840 if (activate) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1841 return FALSE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1842 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1843 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
1844 g_free(proto->name);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1845 g_free(proto);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1846 return TRUE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1847 } else if (!activate) {
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1848 return FALSE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1849 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1850
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1851 proto = g_new0(PidginWebViewProtocol, 1);
33229
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1852 proto->name = g_strdup(name);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1853 proto->length = strlen(name);
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1854 proto->activate = activate;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1855 proto->context_menu = context_menu;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1856 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
1857
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1858 return TRUE;
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1859 }
f9503bfa54a4 Add protocol registration on a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33228
diff changeset
1860
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1861 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1862 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
1863 {
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1864 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
1865 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
1866 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
1867
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1868 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1869
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1870 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
1871 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
1872 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
1873
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1874 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
1875 }
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1876
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1877 static gchar *
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1878 pidgin_webview_strip_smileys(const gchar *text)
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1879 {
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1880 return g_regex_replace(smileys_re, text, -1, 0, "\\1", 0, NULL);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1881 }
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1882
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1883 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1884 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
1885 {
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1886 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
1887 WebKitDOMHTMLElement *body;
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1888 gchar *html, *stripped;
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1889
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1890 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1891
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1892 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
1893 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
1894 html = webkit_dom_html_element_get_inner_html(body);
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1895 stripped = pidgin_webview_strip_smileys(html);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1896 g_free(html);
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1897
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1898 return stripped;
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1899 }
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1900
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1901 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1902 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
1903 {
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1904 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
1905 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
1906 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
1907
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1908 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1909
33004
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1910 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
1911 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
1912 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
1913
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1914 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
1915 }
2a86ad923464 Add some convenience functions to get the contents of a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32994
diff changeset
1916
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1917 gchar *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1918 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
1919 {
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1920 WebKitDOMDocument *dom;
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1921 WebKitDOMDOMWindow *win;
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1922 WebKitDOMDOMSelection *sel;
33254
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1923 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
1924
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1925 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
1926
33014
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1927 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
1928 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
1929 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
1930 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
1931 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
1932
33254
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1933 if (range)
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1934 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
1935 else
88b2504d0acf Fix an warning with selections. Selections are weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33253
diff changeset
1936 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
1937 }
2f8a83007ab9 Set up the link description from the already selected text.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33013
diff changeset
1938
35796
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1939 static gchar *
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1940 pidgin_webview_strip_empty_html(const gchar *text)
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1941 {
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1942 return g_regex_replace(empty_html_re, text, -1, 0, "", 0, NULL);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1943 }
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1944
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1945 gboolean
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1946 pidgin_webview_is_empty(PidginWebView *webview)
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1947 {
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1948 gchar *html, *tmp;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1949 gboolean is_empty;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1950
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1951 g_return_val_if_fail(webview != NULL, TRUE);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1952
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1953 html = pidgin_webview_get_body_html(webview);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1954 tmp = purple_strreplace(html, "&nbsp;", " ");
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1955 g_free(html);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1956 html = tmp;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1957
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1958 tmp = pidgin_webview_strip_empty_html(html);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1959 g_free(html);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1960 html = tmp;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1961
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1962 g_strstrip(html);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1963 is_empty = (html[0] == '\0');
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1964 g_free(html);
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1965
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1966 return is_empty;
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1967 }
bc5253318167 Show smiley images in the input entry and fix some smiley and inline image issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35785
diff changeset
1968
35129
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1969 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1970 pidgin_webview_get_caret(PidginWebView *webview, WebKitDOMNode **container_ret,
35129
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1971 glong *pos_ret)
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1972 {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1973 WebKitDOMDocument *dom;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1974 WebKitDOMDOMWindow *win;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1975 WebKitDOMDOMSelection *sel;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1976 WebKitDOMRange *range = NULL;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1977 WebKitDOMNode *start_container, *end_container;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1978 glong start, end;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1979
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1980 g_return_if_fail(webview && container_ret && pos_ret);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1981
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1982 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1983 win = webkit_dom_document_get_default_view(dom);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1984 sel = webkit_dom_dom_window_get_selection(win);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1985 if (webkit_dom_dom_selection_get_range_count(sel))
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1986 range = webkit_dom_dom_selection_get_range_at(sel, 0, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1987
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1988 if (range) {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1989 start_container = webkit_dom_range_get_start_container(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1990 start = webkit_dom_range_get_start_offset(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1991 end_container = webkit_dom_range_get_end_container(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1992 end = webkit_dom_range_get_end_offset(range, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1993
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1994 if (start == end &&
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1995 webkit_dom_node_is_same_node(start_container, end_container)) {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1996
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1997 *container_ret = start_container;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1998 *pos_ret = start;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
1999 return;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2000 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2001 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2002
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2003 *container_ret = NULL;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2004 *pos_ret = -1;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2005 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2006
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2007 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2008 pidgin_webview_set_caret(PidginWebView *webview, WebKitDOMNode *container, glong pos)
35129
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2009 {
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2010 WebKitDOMDocument *dom;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2011 WebKitDOMDOMWindow *win;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2012 WebKitDOMDOMSelection *sel;
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2013
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2014 g_return_if_fail(webview && container && pos >= 0);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2015
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2016 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2017 win = webkit_dom_document_get_default_view(dom);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2018 sel = webkit_dom_dom_window_get_selection(win);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2019
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2020 webkit_dom_dom_selection_set_position(sel, container, pos, NULL);
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2021 }
22dca763eeef Tab completion
Ankit Vani <a@nevitus.org>
parents: 35047
diff changeset
2022
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2023 PidginWebViewButtons
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2024 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
2025 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2026 PidginWebViewPriv *priv;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2027
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2028 g_return_val_if_fail(webview != NULL, 0);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2029
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2030 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
2031 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
2032 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2033
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2034 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2035 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
2036 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
2037 gboolean *strike)
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2038 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2039 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2040
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2041 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2042
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2043 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
2044
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2045 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
2046 *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
2047 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
2048 *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
2049 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
2050 *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
2051 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
2052 *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
2053 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2054
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2055 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2056 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
2057 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2058 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2059
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2060 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2061
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2062 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
2063 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
2064 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2065
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2066 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2067 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
2068 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2069 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2070
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2071 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2072
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2073 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
2074 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
2075 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2076
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2077 char *
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2078 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
2079 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2080 WebKitDOMDocument *dom;
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2081
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2082 g_return_val_if_fail(webview != NULL, NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2083
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2084 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
2085 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
2086 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2087
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2088 gint
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2089 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
2090 {
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2091 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
2092 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
2093 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
2094
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2095 g_return_val_if_fail(webview != NULL, 0);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2096
32895
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2097 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
2098 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
2099 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
2100 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
2101
fbd3b11e535a WebKit knows the current formatting of the selection better than we
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32894
diff changeset
2102 return size;
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2103 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2104
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2105 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2106 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
2107 {
32813
d1dc6f667a34 Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32812
diff changeset
2108 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
2109
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2110 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2111
32813
d1dc6f667a34 Emit the format-cleared signal when the webview format is cleared.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32812
diff changeset
2112 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
2113 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
2114 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
2115 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2116
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2117 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2118 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
2119 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2120 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2121 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
2122 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2123
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2124 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2125 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
2126 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2127 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2128 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
2129 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2130
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2131 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2132 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
2133 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2134 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2135 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
2136 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2137
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2138 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2139 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
2140 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2141 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2142 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
2143 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2144
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2145 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2146 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
2147 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2148 g_return_val_if_fail(webview != NULL, FALSE);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2149
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
2150 do_formatting(webview, "foreColor", color);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2151 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
2152
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2153 return FALSE;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2154 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2155
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2156 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2157 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
2158 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2159 g_return_val_if_fail(webview != NULL, FALSE);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2160
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
2161 do_formatting(webview, "backColor", color);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2162 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
2163
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2164 return FALSE;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2165 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2166
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2167 gboolean
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2168 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
2169 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2170 g_return_val_if_fail(webview != NULL, FALSE);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2171
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
2172 do_formatting(webview, "fontName", face);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2173 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
2174
32805
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2175 return FALSE;
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2176 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2177
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2178 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2179 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
2180 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2181 char *tmp;
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2182
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2183 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2184
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2185 tmp = g_strdup_printf("%d", size);
33006
86765d2f6f3b Setup WBFO in a WebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33004
diff changeset
2186 do_formatting(webview, "fontSize", tmp);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2187 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
2188 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
2189 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2190
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2191 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2192 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
2193 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2194 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2195 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
2196 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2197
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2198 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2199 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
2200 {
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2201 g_return_if_fail(webview != NULL);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2202 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
2203 }
57f914c32dc4 Copy some editing functions from GtkIMHtml. These are incomplete.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32803
diff changeset
2204
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2205 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2206 pidgin_webview_insert_hr(PidginWebView *webview)
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2207 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2208 PidginWebViewPriv *priv;
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2209 WebKitDOMDocument *dom;
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2210
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2211 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2212
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2213 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33012
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2214 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
2215
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2216 priv->edit.block_changed = TRUE;
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2217 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
2218 priv->edit.block_changed = FALSE;
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2219 }
3a742f00a0f4 Restore Insert Horizontal Rule functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33010
diff changeset
2220
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2221 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2222 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
2223 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2224 PidginWebViewPriv *priv;
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2225 WebKitDOMDocument *dom;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2226 char *link;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2227
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2228 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2229
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2230 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33013
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2231 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
2232 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
2233
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2234 priv->edit.block_changed = TRUE;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2235 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
2236 priv->edit.block_changed = FALSE;
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2237 g_free(link);
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2238 }
f62232fb738a Restore "Insert Link" functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33012
diff changeset
2239
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2240 void
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35798
diff changeset
2241 pidgin_webview_insert_image(PidginWebView *webview, PurpleImage *image)
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2242 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2243 PidginWebViewPriv *priv;
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2244 WebKitDOMDocument *dom;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2245 char *img;
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35798
diff changeset
2246 guint id;
36060
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
2247 gboolean cancel;
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2248
33097
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2249 g_return_if_fail(webview != NULL);
acd0d7217593 Prevent crashing and stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33084
diff changeset
2250
36060
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
2251 g_signal_emit(webview, signals[INSERT_IMAGE], 0, image, &cancel);
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
2252 if (cancel)
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
2253 return;
965aaea4a59b Imgupload: use our own insert image callback for hooked conversations
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35935
diff changeset
2254
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35798
diff changeset
2255 id = purple_image_store_add(image);
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2256 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2257 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
35814
8d99745b6214 imgstore: rip from Pidgin (mostly gtkwebview)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
2258 img = g_strdup_printf("<img src='" PURPLE_IMAGE_STORE_PROTOCOL
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35798
diff changeset
2259 "%u'/>", id);
33017
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2260
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2261 priv->edit.block_changed = TRUE;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2262 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
2263 priv->edit.block_changed = FALSE;
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2264 g_free(img);
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2265 }
d21ab88ad911 Fixup Insert Image functionality.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33016
diff changeset
2266
37196
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2267 static WebKitDOMCSSStyleDeclaration*
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2268 pidgin_webview_get_DOM_CSS_style(PidginWebView *webview)
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2269 {
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2270 WebKitDOMDocument *document;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2271 WebKitDOMElement *dom_element;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2272 WebKitDOMDOMWindow *dom_window;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2273
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2274 document = webkit_web_view_get_dom_document(webview);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2275 dom_window = webkit_dom_document_get_default_view(document);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2276
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2277 dom_element = webkit_dom_document_get_document_element(document);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2278 return webkit_dom_dom_window_get_computed_style(dom_window, dom_element, 0);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2279 }
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2280
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2281 gint
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2282 pidgin_webview_get_DOM_height(PidginWebView *webview)
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2283 {
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2284 gchar *value;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2285 WebKitDOMCSSStyleDeclaration *style;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2286
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2287 style = pidgin_webview_get_DOM_CSS_style(webview);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2288 value = webkit_dom_css_style_declaration_get_property_value(style, "height");
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2289
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2290 return g_ascii_strtoll(value, NULL, 0);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2291 }
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2292
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2293 gint
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2294 pidgin_webview_get_font_size(PidginWebView *webview)
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2295 {
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2296 gchar *value;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2297 WebKitDOMCSSStyleDeclaration *style;
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2298
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2299 style = pidgin_webview_get_DOM_CSS_style(webview);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2300 value = webkit_dom_css_style_declaration_get_property_value(style, "font-size");
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2301
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2302 return g_ascii_strtoll(value, NULL, 0);
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2303 }
7d46a8a4bc58 Set the size of the gtkconv entry
Jorge Villaseñor <salinasv@pidgin.im>
parents: 36060
diff changeset
2304
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2305 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2306 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
2307 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2308 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2309
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2310 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2311
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2312 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2313 priv->toolbar = PIDGIN_WEBVIEWTOOLBAR(toolbar);
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2314 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2315
35935
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2316 GtkWidget *
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2317 pidgin_webview_get_toolbar(PidginWebView *webview)
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2318 {
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2319 PidginWebViewPriv *priv;
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2320
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2321 g_return_val_if_fail(webview != NULL, NULL);
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2322
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2323 priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2324 return GTK_WIDGET(priv->toolbar);
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2325 }
98e92d543d73 Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35913
diff changeset
2326
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2327 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2328 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
2329 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2330 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2331
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2332 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2333
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2334 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
2335 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
2336
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2337 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
2338 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2339
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2340 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2341 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
2342 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2343 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2344
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2345 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2346
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2347 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
2348 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
2349
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2350 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
2351 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2352
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2353 void
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2354 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
2355 {
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2356 PidginWebViewPriv *priv;
34274
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2357
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2358 g_return_if_fail(webview != NULL);
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2359
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2360 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
2361 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
2362
35500
ae6432ea326f Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
2363 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
2364 }
9169710b5af5 Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33877
diff changeset
2365
35713
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2366 void
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2367 pidgin_webview_switch_active_conversation(PidginWebView *webview,
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2368 PurpleConversation *conv)
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2369 {
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2370 PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2371
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2372 g_return_if_fail(priv != NULL);
35716
80bedd712883 Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35714
diff changeset
2373 if (priv->toolbar == NULL)
80bedd712883 Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35714
diff changeset
2374 return;
35713
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2375
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2376 pidgin_webviewtoolbar_switch_active_conversation(priv->toolbar, conv);
4423f463a782 Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35648
diff changeset
2377 }

mercurial