[Xfce4-commits] <midori:master> Use DOM API to get selected text in WebKitGTK+ 1.5.1
Christian Dywan
noreply at xfce.org
Wed Sep 21 23:54:01 CEST 2011
Updating branch refs/heads/master
to 648d869e4ff69f121da97484a0fd553b005ca751 (commit)
from 24604a3db6f609e8df1b991f697155f51351316e (commit)
commit 648d869e4ff69f121da97484a0fd553b005ca751
Author: Christian Dywan <christian at twotoasts.de>
Date: Wed Sep 21 23:50:51 2011 +0200
Use DOM API to get selected text in WebKitGTK+ 1.5.1
Fixes: https://bugs.launchpad.net/midori/+bug/799603
midori/midori-view.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 0d7a96e..e426e7f 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -39,9 +39,11 @@
#include <sys/utsname.h>
#endif
+#if !WEBKIT_CHECK_VERSION (1, 5, 1)
/* This is unstable API, so we need to declare it */
gchar*
webkit_web_view_get_selected_text (WebKitWebView* web_view);
+#endif
static void
midori_view_construct_web_view (MidoriView* view);
@@ -4167,10 +4169,33 @@ midori_view_get_link_uri (MidoriView* view)
gboolean
midori_view_has_selection (MidoriView* view)
{
+#if WEBKIT_CHECK_VERSION (1, 5, 1)
+ WebKitDOMDocument* doc;
+ WebKitDOMDOMWindow* window;
+ WebKitDOMDOMSelection* selection;
+ WebKitDOMRange* range;
+#endif
+
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
+
+#if WEBKIT_CHECK_VERSION (1, 5, 1)
+ doc = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view->web_view));
+ window = webkit_dom_document_get_default_view (doc);
+ selection = webkit_dom_dom_window_get_selection (window);
+ if (selection == NULL)
+ return FALSE;
+
+ range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+ if (range == NULL)
+ return FALSE;
+
+ katze_assign (view->selected_text, webkit_dom_range_get_text (range));
+#else
katze_assign (view->selected_text, webkit_web_view_get_selected_text (
WEBKIT_WEB_VIEW (view->web_view)));
+#endif
+
if (view->selected_text && *view->selected_text)
return TRUE;
else
More information about the Xfce4-commits
mailing list