[epiphany] EphyEmbedEvent: Use G_DECLARE_FINAL_TYPE
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] EphyEmbedEvent: Use G_DECLARE_FINAL_TYPE
- Date: Sat, 7 Nov 2015 16:53:43 +0000 (UTC)
commit d10c6c69a77b2eeb685324e977a1d26ffd9c4be9
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Tue Sep 15 20:07:23 2015 -0500
EphyEmbedEvent: Use G_DECLARE_FINAL_TYPE
embed/ephy-embed-event.c | 62 ++++++++++++---------------------------------
embed/ephy-embed-event.h | 24 +----------------
2 files changed, 19 insertions(+), 67 deletions(-)
---
diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c
index 62d4435..0975cdd 100644
--- a/embed/ephy-embed-event.c
+++ b/embed/ephy-embed-event.c
@@ -22,10 +22,9 @@
#include "config.h"
#include "ephy-embed-event.h"
-#define EPHY_EMBED_EVENT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_EVENT,
EphyEmbedEventPrivate))
+struct _EphyEmbedEvent {
+ GObject parent_instance;
-struct EphyEmbedEventPrivate
-{
guint button;
guint modifier;
guint x;
@@ -38,9 +37,9 @@ G_DEFINE_TYPE (EphyEmbedEvent, ephy_embed_event, G_TYPE_OBJECT)
static void
dispose (GObject *object)
{
- EphyEmbedEventPrivate *priv = EPHY_EMBED_EVENT (object)->priv;
+ EphyEmbedEvent *event = EPHY_EMBED_EVENT (object);
- g_clear_object (&priv->hit_test_result);
+ g_clear_object (&event->hit_test_result);
G_OBJECT_CLASS (ephy_embed_event_parent_class)->dispose (object);
}
@@ -51,30 +50,25 @@ ephy_embed_event_class_init (EphyEmbedEventClass *klass)
GObjectClass *object_class = (GObjectClass *)klass;
object_class->dispose = dispose;
-
- g_type_class_add_private (G_OBJECT_CLASS (klass), sizeof(EphyEmbedEventPrivate));
}
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;
+ embed_event->hit_test_result = g_object_ref (hit_test_result);
+ embed_event->button = event->button;
+ embed_event->modifier = event->state;
+ embed_event->x = event->x;
+ embed_event->y = event->y;
return embed_event;
}
@@ -82,55 +76,41 @@ ephy_embed_event_new (GdkEventButton *event, WebKitHitTestResult *hit_test_resul
guint
ephy_embed_event_get_context (EphyEmbedEvent *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);
+ g_object_get (event->hit_test_result, "context", &context, NULL);
return context;
}
guint
ephy_embed_event_get_button (EphyEmbedEvent *event)
{
- EphyEmbedEventPrivate *priv;
-
g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), 0);
- priv = event->priv;
-
- return priv->button;
+ return event->button;
}
guint
ephy_embed_event_get_modifier (EphyEmbedEvent *event)
{
- EphyEmbedEventPrivate *priv;
-
g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), 0);
- priv = event->priv;
-
- return priv->modifier;
+ return event->modifier;
}
void
ephy_embed_event_get_coords (EphyEmbedEvent *event,
guint *x, guint *y)
{
- EphyEmbedEventPrivate *priv;
-
g_return_if_fail (EPHY_IS_EMBED_EVENT (event));
- priv = event->priv;
-
if (x)
- *x = priv->x;
+ *x = event->x;
if (y)
- *y = priv->y;
+ *y = event->y;
}
/**
@@ -143,32 +123,24 @@ ephy_embed_event_get_property (EphyEmbedEvent *event,
const char *name,
GValue *value)
{
- 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);
+ g_object_get_property (G_OBJECT (event->hit_test_result), name, value);
}
gboolean
ephy_embed_event_has_property (EphyEmbedEvent *event,
const char *name)
{
- EphyEmbedEventPrivate *priv;
-
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),
+ return g_object_class_find_property (G_OBJECT_GET_CLASS (event->hit_test_result),
name) != NULL;
}
@@ -184,5 +156,5 @@ ephy_embed_event_get_hit_test_result (EphyEmbedEvent *event)
{
g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), NULL);
- return event->priv->hit_test_result;
+ return event->hit_test_result;
}
diff --git a/embed/ephy-embed-event.h b/embed/ephy-embed-event.h
index ada5e7e..9e152a2 100644
--- a/embed/ephy-embed-event.h
+++ b/embed/ephy-embed-event.h
@@ -31,30 +31,10 @@
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_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))
+#define EPHY_TYPE_EMBED_EVENT (ephy_embed_event_get_type ())
-typedef struct EphyEmbedEventClass EphyEmbedEventClass;
-typedef struct EphyEmbedEvent EphyEmbedEvent;
-typedef struct EphyEmbedEventPrivate EphyEmbedEventPrivate;
+G_DECLARE_FINAL_TYPE (EphyEmbedEvent, ephy_embed_event, EPHY, EMBED_EVENT, GObject)
-struct EphyEmbedEvent {
- GObject parent_instance;
-
- /*< private >*/
- EphyEmbedEventPrivate *priv;
-};
-
-struct EphyEmbedEventClass {
- GObjectClass parent_class;
-};
-
-
-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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]