aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/Makefile.am2
-rw-r--r--mail/e-mail-display.c84
-rw-r--r--mail/e-mail-display.h3
3 files changed, 66 insertions, 23 deletions
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 09c274aad7..3cc30971f7 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -23,7 +23,6 @@ libevolution_mail_la_CPPFLAGS = \
$(CANBERRA_CFLAGS) \
$(CLUTTER_CFLAGS) \
$(GTKHTML_CFLAGS) \
- $(JAVASCRIPTCORE_CFLAGS) \
$(LIBSOUP_CFLAGS) \
-DEVOLUTION_DATADIR=\""$(datadir)"\" \
-DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
@@ -228,7 +227,6 @@ libevolution_mail_la_LIBADD = \
$(CANBERRA_LIBS) \
$(CLUTTER_LIBS) \
$(GTKHTML_LIBS) \
- $(JAVASCRIPTCORE_CFLAGS) \
$(E_WIDGETS_LIBS) \
$(SMIME_LIBS) \
$(LIBSOUP_LIBS) \
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index ac98b06e5a..2ca422c353 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -49,8 +49,6 @@
#include <camel/camel.h>
-#include <JavaScriptCore/JavaScript.h>
-
#define d(x)
G_DEFINE_TYPE (
@@ -1832,32 +1830,80 @@ e_mail_display_set_status (EMailDisplay *display,
gtk_widget_show_all (GTK_WIDGET (display));
}
+
+static gchar *
+mail_display_get_frame_selection_text (WebKitDOMElement *iframe)
+{
+ WebKitDOMDocument *document;
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *selection;
+ WebKitDOMNodeList *frames;
+ gulong ii, length;
+
+ document = webkit_dom_html_iframe_element_get_content_document (
+ WEBKIT_DOM_HTML_IFRAME_ELEMENT (iframe));
+ window = webkit_dom_document_get_default_view (document);
+ selection = webkit_dom_dom_window_get_selection (window);
+ if (selection && (webkit_dom_dom_selection_get_range_count (selection) > 0)) {
+ WebKitDOMRange *range;
+
+ range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+ if (range) {
+ return webkit_dom_range_to_string (range, NULL);
+ }
+ }
+
+ frames = webkit_dom_document_get_elements_by_tag_name (
+ document, "IFRAME");
+ length = webkit_dom_node_list_get_length (frames);
+ for (ii = 0; ii < length; ii++) {
+ WebKitDOMNode *node;
+ gchar *text;
+
+ node = webkit_dom_node_list_item (frames, ii);
+
+ text = mail_display_get_frame_selection_text (
+ WEBKIT_DOM_ELEMENT (node));
+
+ if (text) {
+ return text;
+ }
+ }
+
+ return NULL;
+}
+
gchar *
-e_mail_display_get_selection_plain_text (EMailDisplay *display,
- gint *len)
+e_mail_display_get_selection_plain_text (EMailDisplay *display)
{
- EWebView *web_view;
- WebKitWebFrame *frame;
- const gchar *frame_name;
- GValue value = {0};
- GType type;
- const gchar *str;
+ WebKitDOMDocument *document;
+ WebKitDOMNodeList *frames;
+ gulong ii, length;
g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
- web_view = E_WEB_VIEW (display);
- frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (web_view));
- frame_name = webkit_web_frame_get_name (frame);
+ if (!webkit_web_view_has_selection (WEBKIT_WEB_VIEW (display)))
+ return NULL;
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (display));
+ frames = webkit_dom_document_get_elements_by_tag_name (document, "IFRAME");
+ length = webkit_dom_node_list_get_length (frames);
- type = e_web_view_frame_exec_script (web_view, frame_name, "window.getSelection().toString()", &value);
- g_return_val_if_fail (type == G_TYPE_STRING, NULL);
+ for (ii = 0; ii < length; ii++) {
+ gchar *text;
+ WebKitDOMNode *node;
- str = g_value_get_string (&value);
+ node = webkit_dom_node_list_item (frames, ii);
- if (len)
- *len = strlen (str);
+ text = mail_display_get_frame_selection_text (
+ WEBKIT_DOM_ELEMENT (node));
- return g_strdup (str);
+ if (text) {
+ return text;
+ }
+ }
+
+ return NULL;
}
void
diff --git a/mail/e-mail-display.h b/mail/e-mail-display.h
index e19895623a..48c16f36a2 100644
--- a/mail/e-mail-display.h
+++ b/mail/e-mail-display.h
@@ -95,8 +95,7 @@ void e_mail_display_set_status (EMailDisplay *display,
const gchar *status);
gchar * e_mail_display_get_selection_plain_text
- (EMailDisplay *display,
- gint *len);
+ (EMailDisplay *display);
void e_mail_display_load_images (EMailDisplay *display);