aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-09 00:26:32 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-09 00:27:37 +0800
commit75595d233ba382dee053d70cf35e26b7eff3befa (patch)
treec1d38c5c8aa1e34f158cb1d8be6626ce0342f898
parentba634a1fb1ea927e37bd59b2a1d99aa7fa184eb4 (diff)
downloadgsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.tar
gsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.tar.gz
gsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.tar.bz2
gsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.tar.lz
gsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.tar.xz
gsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.tar.zst
gsoc2013-evolution-75595d233ba382dee053d70cf35e26b7eff3befa.zip
Bug #683877 - No more contextual menus for links
-rw-r--r--addressbook/gui/widgets/eab-contact-display.c5
-rw-r--r--mail/e-mail-browser.c12
-rw-r--r--modules/mail/e-mail-shell-view-private.c12
-rw-r--r--widgets/misc/e-web-view.c198
-rw-r--r--widgets/misc/e-web-view.h14
5 files changed, 95 insertions, 146 deletions
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
index d6c4238e2f..66928b9f85 100644
--- a/addressbook/gui/widgets/eab-contact-display.c
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -445,8 +445,7 @@ contact_display_load_status_changed (WebKitWebView *web_view,
}
static void
-contact_display_update_actions (EWebView *web_view,
- GdkEventButton *event)
+contact_display_update_actions (EWebView *web_view)
{
GtkActionGroup *action_group;
gboolean scheme_is_internal_mailto;
@@ -456,7 +455,7 @@ contact_display_update_actions (EWebView *web_view,
/* Chain up to parent's update_actions() method. */
E_WEB_VIEW_CLASS (eab_contact_display_parent_class)->
- update_actions (web_view, event);
+ update_actions (web_view);
uri = e_web_view_get_selected_uri (web_view);
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 7535785c35..6b1eb6cd11 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -311,7 +311,6 @@ mail_browser_message_list_built_cb (EMailBrowser *browser,
static gboolean
mail_browser_popup_event_cb (EMailBrowser *browser,
- GdkEventButton *event,
const gchar *uri)
{
EMailReader *reader;
@@ -333,14 +332,9 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
state = e_mail_reader_check_state (reader);
e_mail_reader_update_actions (reader, state);
- if (event == NULL)
- gtk_menu_popup (
- menu, NULL, NULL, NULL, NULL,
- 0, gtk_get_current_event_time ());
- else
- gtk_menu_popup (
- menu, NULL, NULL, NULL, NULL,
- event->button, event->time);
+ gtk_menu_popup (
+ menu, NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
return TRUE;
}
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index 53da2bc288..83a4fa48fe 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -398,7 +398,6 @@ mail_shell_view_message_list_right_click_cb (EShellView *shell_view,
static gboolean
mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
- GdkEventButton *event,
const gchar *uri)
{
EMailShellContent *mail_shell_content;
@@ -424,14 +423,9 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
shell_view = E_SHELL_VIEW (mail_shell_view);
e_shell_view_update_actions (shell_view);
- if (event == NULL)
- gtk_menu_popup (
- menu, NULL, NULL, NULL, NULL,
- 0, gtk_get_current_event_time ());
- else
- gtk_menu_popup (
- menu, NULL, NULL, NULL, NULL,
- event->button, event->time);
+ gtk_menu_popup (
+ menu, NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
return TRUE;
}
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 2400683553..9c434d6cf8 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -867,110 +867,97 @@ web_view_constructed (GObject *object)
}
static gboolean
-web_view_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
+web_view_context_menu_cb (WebKitWebView *webkit_web_view,
+ GtkWidget *default_menu,
+ WebKitHitTestResult *hit_test_result,
+ gboolean triggered_with_keyboard)
{
- GtkWidgetClass *widget_class;
+ WebKitHitTestResultContext context;
EWebView *web_view;
gboolean event_handled = FALSE;
gchar *uri;
- web_view = E_WEB_VIEW (widget);
-
- if (event != NULL) {
- WebKitHitTestResult *test;
- WebKitHitTestResultContext context;
-
- if (web_view->priv->cursor_image != NULL) {
- g_object_unref (web_view->priv->cursor_image);
- web_view->priv->cursor_image = NULL;
- }
-
- if (web_view->priv->cursor_image_src != NULL) {
- g_free (web_view->priv->cursor_image_src);
- web_view->priv->cursor_image_src = NULL;
- }
-
- test = webkit_web_view_get_hit_test_result (
- WEBKIT_WEB_VIEW (web_view), event);
- if (test == NULL)
- goto chainup;
+ web_view = E_WEB_VIEW (webkit_web_view);
- g_object_get (G_OBJECT (test), "context", &context, NULL);
+ if (web_view->priv->cursor_image != NULL) {
+ g_object_unref (web_view->priv->cursor_image);
+ web_view->priv->cursor_image = NULL;
+ }
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) {
- WebKitWebDataSource *data_source;
- WebKitWebFrame *frame;
- GList *subresources, *res;
+ if (web_view->priv->cursor_image_src != NULL) {
+ g_free (web_view->priv->cursor_image_src);
+ web_view->priv->cursor_image_src = NULL;
+ }
- g_object_get (
- G_OBJECT (test), "image-uri", &uri, NULL);
+ if (hit_test_result == NULL)
+ return FALSE;
- if (uri == NULL)
- goto chainup;
+ g_object_get (G_OBJECT (hit_test_result), "context", &context, NULL);
- g_free (web_view->priv->cursor_image_src);
- web_view->priv->cursor_image_src = uri;
+ if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) {
+ WebKitWebDataSource *data_source;
+ WebKitWebFrame *frame;
+ GList *subresources, *res;
- /* Iterate through all resources of the loaded webpage and
- * try to find resource with URI matching cursor_image_src */
- frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
- data_source = webkit_web_frame_get_data_source (frame);
- subresources = webkit_web_data_source_get_subresources (data_source);
- for (res = subresources; res; res = res->next) {
- WebKitWebResource *src = res->data;
- GdkPixbufLoader *loader;
- GString *data;
+ g_object_get (
+ G_OBJECT (hit_test_result), "image-uri", &uri, NULL);
- if (g_strcmp0 (webkit_web_resource_get_uri (src),
- web_view->priv->cursor_image_src) != 0)
- continue;
+ if (uri == NULL)
+ return FALSE;
- data = webkit_web_resource_get_data (src);
- if (data == NULL)
- break;
+ g_free (web_view->priv->cursor_image_src);
+ web_view->priv->cursor_image_src = uri;
- loader = gdk_pixbuf_loader_new ();
- if (!gdk_pixbuf_loader_write (loader,
- (guchar *) data->str, data->len, NULL)) {
- g_object_unref (loader);
- break;
- }
- gdk_pixbuf_loader_close (loader, NULL);
+ /* Iterate through all resources of the loaded webpage and
+ * try to find resource with URI matching cursor_image_src */
+ frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+ data_source = webkit_web_frame_get_data_source (frame);
+ subresources = webkit_web_data_source_get_subresources (data_source);
+ for (res = subresources; res; res = res->next) {
+ WebKitWebResource *src = res->data;
+ GdkPixbufLoader *loader;
+ GString *data;
- if (web_view->priv->cursor_image != NULL)
- g_object_unref (web_view->priv->cursor_image);
+ if (g_strcmp0 (webkit_web_resource_get_uri (src),
+ web_view->priv->cursor_image_src) != 0)
+ continue;
- web_view->priv->cursor_image =
- g_object_ref (gdk_pixbuf_loader_get_animation (loader));
+ data = webkit_web_resource_get_data (src);
+ if (data == NULL)
+ break;
+ loader = gdk_pixbuf_loader_new ();
+ if (!gdk_pixbuf_loader_write (loader,
+ (guchar *) data->str, data->len, NULL)) {
g_object_unref (loader);
break;
}
- g_list_free (subresources);
- }
+ gdk_pixbuf_loader_close (loader, NULL);
+
+ if (web_view->priv->cursor_image != NULL)
+ g_object_unref (web_view->priv->cursor_image);
- g_object_unref (test);
+ web_view->priv->cursor_image =
+ g_object_ref (gdk_pixbuf_loader_get_animation (loader));
+
+ g_object_unref (loader);
+ break;
+ }
+ g_list_free (subresources);
}
- if (event != NULL && event->button != 3)
- goto chainup;
+ g_object_get (hit_test_result, "link-uri", &uri, NULL);
- uri = e_web_view_extract_uri (web_view, event);
+ if (!(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)) {
+ g_free (uri);
+ uri = NULL;
+ }
- g_signal_emit (
- web_view, signals[POPUP_EVENT], 0,
- event, uri, &event_handled);
+ g_signal_emit (web_view, signals[POPUP_EVENT], 0, uri, &event_handled);
g_free (uri);
- if (event_handled)
- return TRUE;
-
-chainup:
- /* Chain up to parent's button_press_event() method. */
- widget_class = GTK_WIDGET_CLASS (e_web_view_parent_class);
- return widget_class->button_press_event (widget, event);
+ return event_handled;
}
static gboolean
@@ -1221,11 +1208,10 @@ web_view_frame_load_uri (EWebView *web_view,
static gboolean
web_view_popup_event (EWebView *web_view,
- GdkEventButton *event,
const gchar *uri)
{
e_web_view_set_selected_uri (web_view, uri);
- e_web_view_show_popup_menu (web_view, event, NULL, NULL);
+ e_web_view_show_popup_menu (web_view);
return TRUE;
}
@@ -1237,8 +1223,7 @@ web_view_stop_loading (EWebView *web_view)
}
static void
-web_view_update_actions (EWebView *web_view,
- GdkEventButton *event)
+web_view_update_actions (EWebView *web_view)
{
GtkActionGroup *action_group;
gboolean can_copy;
@@ -1247,19 +1232,13 @@ web_view_update_actions (EWebView *web_view,
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);
- 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);
+ can_copy = webkit_web_view_can_copy_clipboard (WEBKIT_WEB_VIEW (web_view));
+ has_cursor_image = e_web_view_get_cursor_image_src (web_view) ||
+ e_web_view_get_cursor_image (web_view);
/* Parse the URI early so we know if the actions will work. */
if (uri != NULL) {
@@ -1481,9 +1460,6 @@ e_web_view_class_init (EWebViewClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
-#if 0 /* WEBKIT */
- GtkHTMLClass *html_class;
-#endif
g_type_class_add_private (class, sizeof (EWebViewPrivate));
@@ -1495,7 +1471,6 @@ e_web_view_class_init (EWebViewClass *class)
object_class->constructed = web_view_constructed;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->button_press_event = web_view_button_press_event;
widget_class->scroll_event = web_view_scroll_event;
widget_class->drag_motion = web_view_drag_motion;
@@ -1644,10 +1619,8 @@ e_web_view_class_init (EWebViewClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EWebViewClass, popup_event),
g_signal_accumulator_true_handled, NULL,
- e_marshal_BOOLEAN__BOXED_STRING,
- G_TYPE_BOOLEAN, 2,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
- G_TYPE_STRING);
+ e_marshal_BOOLEAN__STRING,
+ G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
signals[STATUS_MESSAGE] = g_signal_new (
"status-message",
@@ -1674,8 +1647,8 @@ e_web_view_class_init (EWebViewClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EWebViewClass, update_actions),
NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
/* return TRUE when a signal handler processed the mailto URI */
signals[PROCESS_MAILTO] = g_signal_new (
@@ -1740,6 +1713,10 @@ e_web_view_init (EWebView *web_view)
NULL);
g_signal_connect (
+ web_view, "context-menu",
+ G_CALLBACK (web_view_context_menu_cb), NULL);
+
+ g_signal_connect (
web_view, "notify::load-status",
G_CALLBACK (web_view_load_status_changed_cb), NULL);
@@ -2618,27 +2595,19 @@ e_web_view_get_popup_menu (EWebView *web_view)
}
void
-e_web_view_show_popup_menu (EWebView *web_view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data)
+e_web_view_show_popup_menu (EWebView *web_view)
{
GtkWidget *menu;
g_return_if_fail (E_IS_WEB_VIEW (web_view));
- e_web_view_update_actions (web_view, event);
+ e_web_view_update_actions (web_view);
menu = e_web_view_get_popup_menu (web_view);
- if (event != NULL)
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, event->button, event->time);
- else
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, 0, gtk_get_current_event_time ());
+ gtk_menu_popup (
+ GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
}
void
@@ -2659,12 +2628,11 @@ e_web_view_stop_loading (EWebView *web_view)
}
void
-e_web_view_update_actions (EWebView *web_view,
- GdkEventButton *event)
+e_web_view_update_actions (EWebView *web_view)
{
g_return_if_fail (E_IS_WEB_VIEW (web_view));
- g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0, event);
+ g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0);
}
static gchar *
diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h
index bb67a12404..fe17d621c0 100644
--- a/widgets/misc/e-web-view.h
+++ b/widgets/misc/e-web-view.h
@@ -96,13 +96,11 @@ struct _EWebViewClass {
/* Signals */
gboolean (*popup_event) (EWebView *web_view,
- GdkEventButton *event,
const gchar *uri);
void (*status_message) (EWebView *web_view,
const gchar *status_message);
void (*stop_loading) (EWebView *web_view);
- void (*update_actions) (EWebView *web_view,
- GdkEventButton *event);
+ void (*update_actions) (EWebView *web_view);
gboolean (*process_mailto) (EWebView *web_view,
const gchar *mailto_uri);
};
@@ -198,16 +196,12 @@ void e_web_view_zoom_in (EWebView *web_view);
void e_web_view_zoom_out (EWebView *web_view);
GtkUIManager * e_web_view_get_ui_manager (EWebView *web_view);
GtkWidget * e_web_view_get_popup_menu (EWebView *web_view);
-void e_web_view_show_popup_menu (EWebView *web_view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data);
+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,
- GdkEventButton *button);
-gchar * e_web_view_get_selection_html (EWebView *web_view);
+void e_web_view_update_actions (EWebView *web_view);
+gchar * e_web_view_get_selection_html (EWebView *web_view);
void e_web_view_set_settings (EWebView *web_view,
WebKitWebSettings *settings);