aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-web-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc/e-web-view.c')
-rw-r--r--widgets/misc/e-web-view.c100
1 files changed, 69 insertions, 31 deletions
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index beb865b98b..8e1878869e 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -25,8 +25,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
-#include <camel/camel-internet-address.h>
-#include <camel/camel-url.h>
+#include <camel/camel.h>
#include <e-util/e-util.h>
#include <e-util/e-binding.h>
@@ -305,7 +304,7 @@ action_mailto_copy_cb (GtkAction *action,
if (text == NULL || *text == '\0')
text = g_strdup (uri + strlen ("mailto:"));
- camel_object_unref (inet_addr);
+ g_object_unref (inet_addr);
camel_url_free (curl);
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
@@ -767,30 +766,71 @@ web_view_url_requested (GtkHTML *html,
}
static void
-web_view_link_clicked (GtkHTML *html,
- const gchar *uri)
+web_view_gtkhtml_link_clicked (GtkHTML *html,
+ const gchar *uri)
{
- gpointer parent;
+ EWebViewClass *class;
+ EWebView *web_view;
- parent = gtk_widget_get_toplevel (GTK_WIDGET (html));
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+ web_view = E_WEB_VIEW (html);
- e_show_uri (parent, uri);
+ class = E_WEB_VIEW_GET_CLASS (web_view);
+ g_return_if_fail (class->link_clicked != NULL);
+
+ class->link_clicked (web_view, uri);
}
static void
web_view_on_url (GtkHTML *html,
const gchar *uri)
{
+ EWebViewClass *class;
EWebView *web_view;
+
+ web_view = E_WEB_VIEW (html);
+
+ class = E_WEB_VIEW_GET_CLASS (web_view);
+ g_return_if_fail (class->hovering_over_link != NULL);
+
+ /* XXX WebKit would supply a title here. */
+ class->hovering_over_link (web_view, NULL, uri);
+}
+
+static void
+web_view_iframe_created (GtkHTML *html,
+ GtkHTML *iframe)
+{
+ g_signal_connect_swapped (
+ iframe, "button-press-event",
+ G_CALLBACK (web_view_button_press_event_cb), html);
+}
+
+static gchar *
+web_view_extract_uri (EWebView *web_view,
+ GdkEventButton *event,
+ GtkHTML *html)
+{
+ gchar *uri;
+
+ if (event != NULL)
+ uri = gtk_html_get_url_at (html, event->x, event->y);
+ else
+ uri = gtk_html_get_cursor_url (html);
+
+ return uri;
+}
+
+static void
+web_view_hovering_over_link (EWebView *web_view,
+ const gchar *title,
+ const gchar *uri)
+{
CamelInternetAddress *address;
CamelURL *curl;
const gchar *format = NULL;
gchar *message = NULL;
gchar *who;
- web_view = E_WEB_VIEW (html);
-
if (uri == NULL || *uri == '\0')
goto exit;
@@ -816,7 +856,7 @@ web_view_on_url (GtkHTML *html,
address = camel_internet_address_new ();
camel_address_decode (CAMEL_ADDRESS (address), curl->path);
who = camel_address_format (CAMEL_ADDRESS (address));
- camel_object_unref (address);
+ g_object_unref (address);
camel_url_free (curl);
if (who == NULL)
@@ -833,27 +873,25 @@ exit:
}
static void
-web_view_iframe_created (GtkHTML *html,
- GtkHTML *iframe)
+web_view_link_clicked (EWebView *web_view,
+ const gchar *uri)
{
- g_signal_connect_swapped (
- iframe, "button-press-event",
- G_CALLBACK (web_view_button_press_event_cb), html);
+ gpointer parent;
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+ parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+ e_show_uri (parent, uri);
}
-static gchar *
-web_view_extract_uri (EWebView *web_view,
- GdkEventButton *event,
- GtkHTML *html)
+static void
+web_view_load_string (EWebView *web_view,
+ const gchar *string)
{
- gchar *uri;
-
- if (event != NULL)
- uri = gtk_html_get_url_at (html, event->x, event->y);
+ if (string != NULL && *string != '\0')
+ gtk_html_load_from_string (GTK_HTML (web_view), string, -1);
else
- uri = gtk_html_get_cursor_url (html);
-
- return uri;
+ e_web_view_clear (web_view);
}
static void
@@ -1083,11 +1121,13 @@ e_web_view_class_init (EWebViewClass *class)
html_class = GTK_HTML_CLASS (class);
html_class->url_requested = web_view_url_requested;
- html_class->link_clicked = web_view_link_clicked;
+ html_class->link_clicked = web_view_gtkhtml_link_clicked;
html_class->on_url = web_view_on_url;
html_class->iframe_created = web_view_iframe_created;
class->extract_uri = web_view_extract_uri;
+ class->hovering_over_link = web_view_hovering_over_link;
+ class->link_clicked = web_view_link_clicked;
class->load_string = web_view_load_string;
class->copy_clipboard = web_view_copy_clipboard;
class->cut_clipboard = web_view_cut_clipboard;
@@ -1122,7 +1162,6 @@ e_web_view_class_init (EWebViewClass *class)
PROP_COPY_TARGET_LIST,
"copy-target-list");
-#ifndef G_OS_WIN32
g_object_class_install_property (
object_class,
PROP_DISABLE_PRINTING,
@@ -1144,7 +1183,6 @@ e_web_view_class_init (EWebViewClass *class)
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
-#endif
g_object_class_install_property (
object_class,