aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorXan Lopez <xan@gnome.org>2009-09-20 05:06:01 +0800
committerXan Lopez <xan@gnome.org>2009-09-20 05:06:01 +0800
commit98361f61fcdfc52d2ae2682234778f3e1b384916 (patch)
treeb31f644a5fb16a636cf872408840e4cba971bc86 /embed
parent0fa8e2fb6780e75923da248bb5d94e30d8556dd7 (diff)
downloadgsoc2013-epiphany-98361f61fcdfc52d2ae2682234778f3e1b384916.tar.gz
gsoc2013-epiphany-98361f61fcdfc52d2ae2682234778f3e1b384916.tar.zst
gsoc2013-epiphany-98361f61fcdfc52d2ae2682234778f3e1b384916.zip
Bring back epiphany context menu
There's a few items (like email link) and actions (like bookmark link) missing or not working because of missing information in the WebKitHitTestResult object, but most of the stuff is working. For some reason the g-ir-scanner is not picking up the correct type name for WebKitHitTestResult (it uses WebKitHitTestResult instead of WebKit.HitTestResult), so the introspection support is broken unless that error is fixed manually. Looking into that ... Bug #562617
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-event.c165
-rw-r--r--embed/ephy-embed-event.h88
-rw-r--r--embed/ephy-web-view.c19
-rw-r--r--embed/ephy-web-view.h2
4 files changed, 150 insertions, 124 deletions
diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c
index 352215ae2..c217e6951 100644
--- a/embed/ephy-embed-event.c
+++ b/embed/ephy-embed-event.c
@@ -1,5 +1,7 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2000-2003 Marco Pesenti Gritti
+ * Copyright © 2009 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,87 +27,152 @@
#include <glib.h>
#include <gtk/gtk.h>
-static void ephy_embed_event_base_init (gpointer g_class);
+#define EPHY_EMBED_EVENT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventPrivate))
-GType
-ephy_embed_event_get_type (void)
+struct EphyEmbedEventPrivate
{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- const GTypeInfo our_info =
- {
- sizeof (EphyEmbedEventIface),
- ephy_embed_event_base_init,
- NULL,
- };
-
- type = g_type_register_static (G_TYPE_INTERFACE,
- "EphyEmbedEvent",
- &our_info,
- (GTypeFlags) 0);
- }
-
- return type;
+ guint button;
+ guint modifier;
+ guint x;
+ guint y;
+ WebKitHitTestResult *hit_test_result;
+};
+
+G_DEFINE_TYPE (EphyEmbedEvent, ephy_embed_event, G_TYPE_OBJECT)
+
+static void
+dispose (GObject *object)
+{
+ EphyEmbedEventPrivate *priv = EPHY_EMBED_EVENT (object)->priv;
+
+ if (priv->hit_test_result) {
+ g_object_unref (priv->hit_test_result);
+ priv->hit_test_result = NULL;
+ }
+
+ G_OBJECT_CLASS (ephy_embed_event_parent_class)->dispose (object);
}
static void
-ephy_embed_event_base_init (gpointer g_class)
+ephy_embed_event_class_init (EphyEmbedEventClass *klass)
{
- static gboolean initialised = FALSE;
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ object_class->dispose = dispose;
- initialised = TRUE;
+ g_type_class_add_private (G_OBJECT_CLASS (klass), sizeof(EphyEmbedEventPrivate));
}
-EphyEmbedEventContext
+static void
+ephy_embed_event_init (EphyEmbedEvent *embed_event)
+{
+ embed_event->priv = EPHY_EMBED_EVENT_GET_PRIVATE (embed_event);
+}
+
+EphyEmbedEvent *
+ephy_embed_event_new (GdkEventButton *event, WebKitHitTestResult *hit_test_result)
+{
+ EphyEmbedEvent *embed_event;
+ EphyEmbedEventPrivate *priv;
+
+ embed_event = g_object_new (EPHY_TYPE_EMBED_EVENT, NULL);
+ priv = embed_event->priv;
+
+ priv->hit_test_result = g_object_ref (hit_test_result);
+ priv->button = event->button;
+ priv->modifier = event->state;
+ priv->x = event->x;
+ priv->y = event->y;
+
+ return embed_event;
+}
+
+guint
ephy_embed_event_get_context (EphyEmbedEvent *event)
{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_context (event);
+ EphyEmbedEventPrivate *priv;
+ guint context;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), 0);
+
+ priv = event->priv;
+ g_object_get (priv->hit_test_result, "context", &context, NULL);
+ return context;
}
guint
ephy_embed_event_get_button (EphyEmbedEvent *event)
{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_button (event);
+ EphyEmbedEventPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), 0);
+
+ priv = event->priv;
+
+ return priv->button;
}
guint
ephy_embed_event_get_modifier (EphyEmbedEvent *event)
{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_modifier (event);
+ EphyEmbedEventPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), 0);
+
+ priv = event->priv;
+
+ return priv->modifier;
}
void
ephy_embed_event_get_coords (EphyEmbedEvent *event,
- guint *x, guint *y)
+ guint *x, guint *y)
{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- iface->get_coordinates (event, x, y);
+ EphyEmbedEventPrivate *priv;
+
+ g_return_if_fail (EPHY_IS_EMBED_EVENT (event));
+
+ priv = event->priv;
+
+ if (x)
+ *x = priv->x;
+
+ if (y)
+ *y = priv->y;
}
-const GValue*
-ephy_embed_event_get_property (EphyEmbedEvent *event,
- const char *name)
+void
+ephy_embed_event_get_property (EphyEmbedEvent *event,
+ const char *name,
+ GValue *value)
{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_property (event, name);
+ EphyEmbedEventPrivate *priv;
+
+ g_return_if_fail (EPHY_IS_EMBED_EVENT (event));
+ g_return_if_fail (name);
+
+ priv = event->priv;
+
+ /* FIXME: ugly hack! This only works for now because all properties
+ we have are strings */
+ g_value_init (value, G_TYPE_STRING);
+
+ g_object_get_property (G_OBJECT (priv->hit_test_result), name, value);
}
gboolean
-ephy_embed_event_has_property (EphyEmbedEvent *event,
- const char *name)
+ephy_embed_event_has_property (EphyEmbedEvent *event,
+ const char *name)
{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->has_property (event, name);
-}
+ EphyEmbedEventPrivate *priv;
-gpointer
-ephy_embed_event_get_dom_event (EphyEmbedEvent *event)
-{
- EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_dom_event (event);
+ g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), FALSE);
+ g_return_val_if_fail (name, FALSE);
+
+ priv = event->priv;
+
+ return g_object_class_find_property (G_OBJECT_GET_CLASS (priv->hit_test_result),
+ name) != NULL;
+
}
+
diff --git a/embed/ephy-embed-event.h b/embed/ephy-embed-event.h
index 0c7d9aa8c..6347be957 100644
--- a/embed/ephy-embed-event.h
+++ b/embed/ephy-embed-event.h
@@ -1,6 +1,8 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2000-2003 Marco Pesenti Gritti
* Copyright © 2004 Christian Persch
+ * Copyright © 2009 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,71 +29,47 @@
#include <glib-object.h>
#include <glib.h>
+#include <webkit/webkit.h>
G_BEGIN_DECLS
-#define EPHY_TYPE_EMBED_EVENT (ephy_embed_event_get_type ())
-#define EPHY_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_EMBED_EVENT, EphyEmbedEvent))
-#define EPHY_EMBED_EVENT_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventIface))
-#define EPHY_IS_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED_EVENT))
-#define EPHY_IS_EMBED_EVENT_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED_EVENT))
-#define EPHY_EMBED_EVENT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventIface))
+#define EPHY_TYPE_EMBED_EVENT (ephy_embed_event_get_type ())
+#define EPHY_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_EMBED_EVENT, EphyEmbedEvent))
+#define EPHY_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventClass))
+#define EPHY_IS_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED_EVENT))
+#define EPHY_IS_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED_EVENT))
+#define EPHY_EMBED_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventClass))
-typedef struct _EphyEmbedEventIface EphyEmbedEventIface;
-typedef struct _EphyEmbedEvent EphyEmbedEvent;
+typedef struct EphyEmbedEventClass EphyEmbedEventClass;
+typedef struct EphyEmbedEvent EphyEmbedEvent;
+typedef struct EphyEmbedEventPrivate EphyEmbedEventPrivate;
-typedef enum
-{
- EPHY_EMBED_CONTEXT_NONE = 0,
- EPHY_EMBED_CONTEXT_DEFAULT = 1 << 1,
- EPHY_EMBED_CONTEXT_LINK = 1 << 2,
- EPHY_EMBED_CONTEXT_IMAGE = 1 << 3,
- EPHY_EMBED_CONTEXT_DOCUMENT = 1 << 4,
- EPHY_EMBED_CONTEXT_INPUT = 1 << 5,
- EPHY_EMBED_CONTEXT_INPUT_PASSWORD = 1 << 6,
- EPHY_EMBED_CONTEXT_XUL = 1 << 7,
- EPHY_EMBED_CONTEXT_EMAIL_LINK = 1 << 8
-} EphyEmbedEventContext;
+struct EphyEmbedEvent {
+ GObject parent_instance;
-struct _EphyEmbedEventIface
-{
- GTypeInterface parent_iface;
-
- /* Methods */
- EphyEmbedEventContext (* get_context) (EphyEmbedEvent *event);
- guint (* get_button) (EphyEmbedEvent *event);
- guint (* get_modifier) (EphyEmbedEvent *event);
- void (* get_coordinates) (EphyEmbedEvent *event,
- guint *x,
- guint *y);
- const GValue* (* get_property) (EphyEmbedEvent *event,
- const char *name);
- gboolean (* has_property) (EphyEmbedEvent *event,
- const char *name);
- gpointer (* get_dom_event) (EphyEmbedEvent *event);
+ /*< private >*/
+ EphyEmbedEventPrivate *priv;
};
-GType ephy_embed_event_get_type (void);
-
-GType ephy_embed_event_context_get_type (void);
-
-EphyEmbedEventContext ephy_embed_event_get_context (EphyEmbedEvent *event);
-
-guint ephy_embed_event_get_button (EphyEmbedEvent *event);
-
-guint ephy_embed_event_get_modifier (EphyEmbedEvent *event);
-
-
-void ephy_embed_event_get_coords (EphyEmbedEvent *event,
- guint *x, guint *y);
-
-const GValue* ephy_embed_event_get_property (EphyEmbedEvent *event,
- const char *name);
+struct EphyEmbedEventClass {
+ GObjectClass parent_class;
+};
-gboolean ephy_embed_event_has_property (EphyEmbedEvent *event,
- const char *name);
-gpointer ephy_embed_event_get_dom_event (EphyEmbedEvent *event);
+GType ephy_embed_event_get_type (void);
+EphyEmbedEvent *ephy_embed_event_new (GdkEventButton *event,
+ WebKitHitTestResult *hit_test_result);
+guint ephy_embed_event_get_context (EphyEmbedEvent *event);
+guint ephy_embed_event_get_button (EphyEmbedEvent *event);
+guint ephy_embed_event_get_modifier (EphyEmbedEvent *event);
+void ephy_embed_event_get_coords (EphyEmbedEvent *event,
+ guint *x,
+ guint *y);
+void ephy_embed_event_get_property (EphyEmbedEvent *event,
+ const char *name,
+ GValue *value);
+gboolean ephy_embed_event_has_property (EphyEmbedEvent *event,
+ const char *name);
G_END_DECLS
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 5f1f49af0..3ef682669 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -688,24 +688,7 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
-/**
- * EphyWebView::ge-context-menu:
- * @embed:
- * @event: the #EphyEmbedEvent which triggered this signal
- *
- * The ::ge_context_menu signal is emitted when a context menu is to be
- * displayed. This will usually happen when the user right-clicks on a part of
- * @embed.
- **/
- g_signal_new ("ge_context_menu",
- EPHY_TYPE_WEB_VIEW,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyWebViewClass, context_menu),
- g_signal_accumulator_true_handled, NULL,
- ephy_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN,
- 1,
- G_TYPE_OBJECT);
+
/**
* EphyWebView::ge-favicon:
* @embed:
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 29f1bd34b..6625689f3 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -121,8 +121,6 @@ struct _EphyWebViewClass
WebKitWebViewClass parent_class;
/* Signals */
- int (* context_menu) (EphyWebView *view,
- EphyEmbedEvent *event);
void (* favicon) (EphyWebView *view,
const char *location);
void (* feed_link) (EphyWebView *view,