aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-06-18 19:39:50 +0800
committerDan Vrátil <dvratil@redhat.com>2012-06-18 19:42:39 +0800
commit031c40a51791b2ebcd44f880c96860b987e1a00c (patch)
tree641acc9c69ab39a6d2aa9af724c30e438f5e3710
parent88a372b27e655eaaa27e7b806a1adc360b1583b6 (diff)
downloadgsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.tar
gsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.tar.gz
gsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.tar.bz2
gsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.tar.lz
gsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.tar.xz
gsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.tar.zst
gsoc2013-evolution-031c40a51791b2ebcd44f880c96860b987e1a00c.zip
Bug #764467 - URL popup shows all Copy options
-rw-r--r--addressbook/gui/widgets/eab-contact-display.c5
-rw-r--r--mail/e-mail-display.c71
-rw-r--r--widgets/misc/e-web-view.c35
-rw-r--r--widgets/misc/e-web-view.h7
4 files changed, 58 insertions, 60 deletions
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
index 677d258439..28fd5b02be 100644
--- a/addressbook/gui/widgets/eab-contact-display.c
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -418,7 +418,8 @@ contact_display_load_status_changed (WebKitWebView *web_view,
}
static void
-contact_display_update_actions (EWebView *web_view)
+contact_display_update_actions (EWebView *web_view,
+ GdkEventButton *event)
{
GtkActionGroup *action_group;
gboolean scheme_is_internal_mailto;
@@ -427,7 +428,7 @@ contact_display_update_actions (EWebView *web_view)
const gchar *uri;
/* Chain up to parent's update_actions() method. */
- E_WEB_VIEW_CLASS (parent_class)->update_actions (web_view);
+ E_WEB_VIEW_CLASS (parent_class)->update_actions (web_view, event);
uri = e_web_view_get_selected_uri (web_view);
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 461fb8f72d..1b4b284720 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -66,9 +66,6 @@ struct _EMailDisplayPrivate {
gboolean headers_collapsable;
gboolean headers_collapsed;
- GtkActionGroup *mailto_actions;
- GtkActionGroup *images_actions;
-
gint force_image_load: 1;
GSettings *settings;
@@ -165,16 +162,29 @@ static GtkActionEntry image_entries[] = {
};
static void
-mail_display_webview_update_actions (EWebView *web_view,
- gpointer user_data)
+mail_display_update_actions (EWebView *web_view,
+ GdkEventButton *event)
{
- const gchar *image_src;
+ WebKitHitTestResult *hit_test;
+ WebKitHitTestResultContext context;
+ gchar *image_src;
gboolean visible;
GtkAction *action;
- g_return_if_fail (web_view != NULL);
+ /* Chain up first! */
+ E_WEB_VIEW_CLASS (parent_class)->update_actions (web_view, event);
+
+ hit_test = webkit_web_view_get_hit_test_result (
+ WEBKIT_WEB_VIEW (web_view), event);
+ g_object_get (
+ G_OBJECT (hit_test),
+ "context", &context,
+ "image-uri", &image_src,
+ NULL);
+
+ if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE))
+ return;
- image_src = e_web_view_get_cursor_image_src (web_view);
visible = image_src && g_str_has_prefix (image_src, "cid:");
if (!visible && image_src) {
CamelStream *image_stream;
@@ -187,6 +197,9 @@ mail_display_webview_update_actions (EWebView *web_view,
g_object_unref (image_stream);
}
+ if (image_src)
+ g_free (image_src);
+
action = e_web_view_get_action (web_view, "image-save");
if (action)
gtk_action_set_visible (action, visible);
@@ -1350,6 +1363,7 @@ e_mail_display_class_init (EMailDisplayClass *class)
web_view_class = E_WEB_VIEW_CLASS (class);
web_view_class->set_fonts = mail_display_set_fonts;
+ web_view_class->update_actions = mail_display_update_actions;
widget_class = GTK_WIDGET_CLASS (class);
widget_class->realize = mail_display_realize;
@@ -1401,10 +1415,10 @@ static void
e_mail_display_init (EMailDisplay *display)
{
GtkUIManager *ui_manager;
- GError *error = NULL;
const gchar *user_cache_dir;
WebKitWebSettings *settings;
WebKitWebFrame *main_frame;
+ GtkActionGroup *actions;
display->priv = E_MAIL_DISPLAY_GET_PRIVATE (display);
@@ -1413,13 +1427,6 @@ e_mail_display_init (EMailDisplay *display)
display->priv->mode = E_MAIL_FORMATTER_MODE_INVALID;
e_mail_display_set_mode (display, E_MAIL_FORMATTER_MODE_NORMAL);
display->priv->force_image_load = FALSE;
- display->priv->mailto_actions = gtk_action_group_new ("mailto");
- gtk_action_group_add_actions (display->priv->mailto_actions, mailto_entries,
- G_N_ELEMENTS (mailto_entries), NULL);
-
- display->priv->images_actions = gtk_action_group_new ("image");
- gtk_action_group_add_actions (display->priv->images_actions, image_entries,
- G_N_ELEMENTS (image_entries), NULL);
webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (display), TRUE);
@@ -1432,8 +1439,6 @@ e_mail_display_init (EMailDisplay *display)
G_CALLBACK (mail_display_resource_requested), NULL);
g_signal_connect (display, "process-mailto",
G_CALLBACK (mail_display_process_mailto), NULL);
- g_signal_connect (display, "update-actions",
- G_CALLBACK (mail_display_webview_update_actions), NULL);
g_signal_connect (display, "create-plugin-widget",
G_CALLBACK (mail_display_plugin_widget_requested), NULL);
g_signal_connect (display, "frame-created",
@@ -1461,26 +1466,16 @@ e_mail_display_init (EMailDisplay *display)
g_signal_connect (main_frame, "notify::load-status",
G_CALLBACK (mail_parts_bind_dom), NULL);
- /* Because we are loading from a hard-coded string, there is
- * no chance of I/O errors. Failure here implies a malformed
- * UI definition. Full stop. */
+ actions = e_web_view_get_action_group (E_WEB_VIEW (display), "mailto");
+ gtk_action_group_add_actions (
+ actions, mailto_entries, G_N_ELEMENTS (mailto_entries), display);
ui_manager = e_web_view_get_ui_manager (E_WEB_VIEW (display));
- gtk_ui_manager_insert_action_group (ui_manager, display->priv->mailto_actions, 0);
- gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
-
- if (error != NULL) {
- g_error ("%s", error->message);
- g_error_free (error);
- }
+ gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
- error = NULL;
- gtk_ui_manager_insert_action_group (ui_manager, display->priv->images_actions, 0);
- gtk_ui_manager_add_ui_from_string (ui_manager, image_ui, -1, &error);
-
- if (error != NULL) {
- g_error ("%s", error->message);
- g_error_free (error);
- }
+ actions = e_web_view_get_action_group (E_WEB_VIEW (display), "image");
+ gtk_action_group_add_actions (
+ actions, image_entries, G_N_ELEMENTS (image_entries), display);
+ gtk_ui_manager_add_ui_from_string (ui_manager, image_ui, -1, NULL);
e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_MAIL_REQUEST);
e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_HTTP_REQUEST);
@@ -1728,9 +1723,7 @@ e_mail_display_get_action (EMailDisplay *display,
g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
g_return_val_if_fail (action_name != NULL, NULL);
- action = gtk_action_group_get_action (display->priv->mailto_actions, action_name);
- if (!action)
- action = gtk_action_group_get_action (display->priv->images_actions, action_name);
+ action = e_web_view_get_action (E_WEB_VIEW (display), action_name);
return action;
}
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index f3728dbd5d..9cf4f669dd 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -882,7 +882,6 @@ web_view_button_press_event (GtkWidget *widget,
}
test = webkit_web_view_get_hit_test_result (WEBKIT_WEB_VIEW (web_view), event);
-
if (!test)
goto chainup;
@@ -946,11 +945,6 @@ web_view_button_press_event (GtkWidget *widget,
uri = e_web_view_extract_uri (web_view, event);
- if (uri != NULL && g_str_has_prefix (uri, "##")) {
- g_free (uri);
- goto chainup;
- }
-
g_signal_emit (
web_view, signals[POPUP_EVENT], 0,
event, uri, &event_handled);
@@ -1227,21 +1221,29 @@ web_view_stop_loading (EWebView *web_view)
}
static void
-web_view_update_actions (EWebView *web_view)
+web_view_update_actions (EWebView *web_view,
+ GdkEventButton *event)
{
GtkActionGroup *action_group;
- gboolean have_selection;
+ gboolean can_copy;
gboolean scheme_is_http = FALSE;
gboolean scheme_is_mailto = FALSE;
gboolean uri_is_valid = FALSE;
gboolean has_cursor_image;
gboolean visible;
+ WebKitHitTestResult *hit_test;
+ WebKitHitTestResultContext context;
const gchar *group_name;
const gchar *uri;
uri = e_web_view_get_selected_uri (web_view);
- have_selection = e_web_view_is_selection_active (web_view);
- has_cursor_image = e_web_view_get_cursor_image (web_view) != NULL;
+ can_copy = webkit_web_view_can_copy_clipboard (
+ WEBKIT_WEB_VIEW (web_view));
+ hit_test = webkit_web_view_get_hit_test_result (
+ WEBKIT_WEB_VIEW (web_view), event);
+ g_object_get (G_OBJECT (hit_test), "context", &context, NULL);
+
+ has_cursor_image = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE);
/* Parse the URI early so we know if the actions will work. */
if (uri != NULL) {
@@ -1281,7 +1283,7 @@ web_view_update_actions (EWebView *web_view)
gtk_action_group_set_visible (action_group, visible);
group_name = "selection";
- visible = have_selection;
+ visible = can_copy;
action_group = e_web_view_get_action_group (web_view, group_name);
gtk_action_group_set_visible (action_group, visible);
@@ -1646,8 +1648,8 @@ e_web_view_class_init (EWebViewClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EWebViewClass, update_actions),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
/* return TRUE when a signal handler processed the mailto URI */
signals[PROCESS_MAILTO] = g_signal_new (
@@ -2760,7 +2762,7 @@ e_web_view_show_popup_menu (EWebView *web_view,
g_return_if_fail (E_IS_WEB_VIEW (web_view));
- e_web_view_update_actions (web_view);
+ e_web_view_update_actions (web_view, event);
menu = e_web_view_get_popup_menu (web_view);
@@ -2792,11 +2794,12 @@ e_web_view_stop_loading (EWebView *web_view)
}
void
-e_web_view_update_actions (EWebView *web_view)
+e_web_view_update_actions (EWebView *web_view,
+ GdkEventButton *event)
{
g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0);
+ g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0, event);
}
gchar *
diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h
index af6dbb1502..66e65c2df5 100644
--- a/widgets/misc/e-web-view.h
+++ b/widgets/misc/e-web-view.h
@@ -102,7 +102,8 @@ struct _EWebViewClass {
void (*status_message) (EWebView *web_view,
const gchar *status_message);
void (*stop_loading) (EWebView *web_view);
- void (*update_actions) (EWebView *web_view);
+ void (*update_actions) (EWebView *web_view,
+ GdkEventButton *event);
gboolean (*process_mailto) (EWebView *web_view,
const gchar *mailto_uri);
};
@@ -218,8 +219,8 @@ void e_web_view_show_popup_menu (EWebView *web_view,
void e_web_view_status_message (EWebView *web_view,
const gchar *status_message);
void e_web_view_stop_loading (EWebView *web_view);
-void e_web_view_update_actions (EWebView *web_view);
-
+void e_web_view_update_actions (EWebView *web_view,
+ GdkEventButton *button);
gchar * e_web_view_get_selection_html (EWebView *web_view);
void e_web_view_set_settings (EWebView *web_view,