diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-01-16 02:08:26 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-01-16 02:08:26 +0800 |
commit | 216c6fa203c77b1ea3aa21dd822c3688783cac42 (patch) | |
tree | 4fcc01185a3bc213497bfcf90fbdc47b6044becf /embed/ephy-embed-event.c | |
parent | 5e2c715ab1b0ae755542a02914b2377fd0878d99 (diff) | |
download | gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.gz gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.bz2 gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.lz gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.xz gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.zst gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.zip |
Make EphyEmbedEvent abstract, implemented by MozillaEmbedEvent. Port
2004-01-15 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-event.c: (ephy_embed_event_get_type),
(ephy_embed_event_base_init), (ephy_embed_event_get_event_type),
(ephy_embed_event_get_context), (ephy_embed_event_get_modifier),
(ephy_embed_event_get_coords), (ephy_embed_event_get_property),
(ephy_embed_event_has_property), (ephy_embed_event_get_dom_event):
* embed/ephy-embed-event.h:
* embed/mozilla/EventContext.cpp:
* embed/mozilla/EventContext.h:
* embed/mozilla/Makefile.am:
* embed/mozilla/mozilla-embed-event.cpp:
* embed/mozilla/mozilla-embed-event.h:
* embed/mozilla/mozilla-embed.cpp:
* src/ephy-window.c: (popup_menu_at_coords):
* src/popup-commands.c: (popup_cmd_copy_link_address):
Make EphyEmbedEvent abstract, implemented by MozillaEmbedEvent.
Port callers to the new api.
Fix some callers in src/ which were using private fields of
EphyEmbedEvent struct.
Diffstat (limited to 'embed/ephy-embed-event.c')
-rw-r--r-- | embed/ephy-embed-event.c | 124 |
1 files changed, 36 insertions, 88 deletions
diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c index bc99b81bf..1271e29ed 100644 --- a/embed/ephy-embed-event.c +++ b/embed/ephy-embed-event.c @@ -30,122 +30,66 @@ struct EphyEmbedEventPrivate GHashTable *props; }; -static void -ephy_embed_event_class_init (EphyEmbedEventClass *klass); -static void -ephy_embed_event_init (EphyEmbedEvent *ges); -static void -ephy_embed_event_finalize (GObject *object); - -static GObjectClass *parent_class = NULL; +static void ephy_embed_event_base_init (gpointer g_class); GType ephy_embed_event_get_type (void) { - static GType ephy_embed_event_type = 0; + static GType type = 0; - if (ephy_embed_event_type == 0) + if (type == 0) { static const GTypeInfo our_info = { - sizeof (EphyEmbedEventClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ephy_embed_event_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EphyEmbedEvent), - 0, /* n_preallocs */ - (GInstanceInitFunc) ephy_embed_event_init + sizeof (EphyEmbedEventIFace), + ephy_embed_event_base_init, + NULL, }; - ephy_embed_event_type = g_type_register_static (G_TYPE_OBJECT, - "EphyEmbedEvent", - &our_info, 0); + type = g_type_register_static (G_TYPE_INTERFACE, + "EphyEmbedEvent", + &our_info, + (GTypeFlags) 0); } - return ephy_embed_event_type; -} - -static void -ephy_embed_event_class_init (EphyEmbedEventClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = ephy_embed_event_finalize; - - g_type_class_add_private (object_class, sizeof(EphyEmbedEventPrivate)); -} - -static void -free_g_value (gpointer value) -{ - g_value_unset (value); - g_free (value); + return type; } static void -ephy_embed_event_init (EphyEmbedEvent *event) +ephy_embed_event_base_init (gpointer g_class) { - event->priv = EPHY_EMBED_EVENT_GET_PRIVATE (event); + static gboolean initialised = FALSE; - event->priv->props = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, free_g_value); + initialised = TRUE; } -static void -ephy_embed_event_finalize (GObject *object) +EphyEmbedEventType +ephy_embed_event_get_event_type (EphyEmbedEvent *event) { - EphyEmbedEvent *event = EPHY_EMBED_EVENT (object); - - g_hash_table_destroy (event->priv->props); - - G_OBJECT_CLASS (parent_class)->finalize (object); + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + return iface->get_type (event); } - -EphyEmbedEvent * -ephy_embed_event_new (void) +EmbedEventContext +ephy_embed_event_get_context (EphyEmbedEvent *event) { - return EPHY_EMBED_EVENT (g_object_new (EPHY_TYPE_EMBED_EVENT, NULL)); + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + return iface->get_context (event); } guint ephy_embed_event_get_modifier (EphyEmbedEvent *event) { - return event->modifier; -} - -EphyEmbedEventType -ephy_embed_event_get_event_type (EphyEmbedEvent *event) -{ - return event->type; + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + return iface->get_modifier (event); } void ephy_embed_event_get_coords (EphyEmbedEvent *event, guint *x, guint *y) { - *x = event->x; - *y = event->y; -} - -EmbedEventContext -ephy_embed_event_get_context (EphyEmbedEvent *event) -{ - return event->context; -} - -void -ephy_embed_event_set_property (EphyEmbedEvent *event, - const char *name, - GValue *value) -{ - g_hash_table_insert (event->priv->props, - g_strdup (name), - value); + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + iface->get_coordinates (event, x, y); } void @@ -153,17 +97,21 @@ ephy_embed_event_get_property (EphyEmbedEvent *event, const char *name, const GValue **value) { - *value = g_hash_table_lookup (event->priv->props, name); + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + iface->get_property (event, name, value); } gboolean ephy_embed_event_has_property (EphyEmbedEvent *event, const char *name) { - gpointer tmp; - - tmp = g_hash_table_lookup (event->priv->props, - name); + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + return iface->has_property (event, name); +} - return tmp != NULL; +gpointer +ephy_embed_event_get_dom_event (EphyEmbedEvent *event) +{ + EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event); + return iface->get_dom_event (event); } |