From: Pierre-Luc Beaudoin Date: Thu, 26 Feb 2009 19:25:01 +0000 (+0200) Subject: GObjectify ChamplainLayer X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=240e8ab71bfed218154836ded9b4c76639dd8677;p=libchamplain GObjectify ChamplainLayer This one wasn't planned, but the previous implementation wasn't bindings friendly. --- diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c index 34bfa53..e1e2127 100644 --- a/champlain/champlain-layer.c +++ b/champlain/champlain-layer.c @@ -36,6 +36,86 @@ #include #include +G_DEFINE_TYPE (ChamplainLayer, champlain_layer, CLUTTER_TYPE_GROUP) + +#define GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_LAYER, ChamplainLayerPrivate)) + +enum +{ + PROP_0 +}; + +typedef struct _ChamplainLayerPrivate ChamplainLayerPrivate; + +struct _ChamplainLayerPrivate { + gpointer spacer; +}; + +static void layer_add_cb (ClutterGroup *layer, ClutterActor *marker, + gpointer data); + +static void +champlain_layer_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ChamplainLayer *self = CHAMPLAIN_LAYER (object); + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +champlain_layer_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + ChamplainLayer *self = CHAMPLAIN_LAYER (object); + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +champlain_layer_dispose (GObject *object) +{ + ChamplainLayerPrivate *priv = GET_PRIVATE (object); + + G_OBJECT_CLASS (champlain_layer_parent_class)->dispose (object); +} + +static void +champlain_layer_finalize (GObject *object) +{ + G_OBJECT_CLASS (champlain_layer_parent_class)->finalize (object); +} + +static void +champlain_layer_class_init (ChamplainLayerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (ChamplainLayerPrivate)); + + object_class->get_property = champlain_layer_get_property; + object_class->set_property = champlain_layer_set_property; + object_class->dispose = champlain_layer_dispose; + object_class->finalize = champlain_layer_finalize; +} + +static void +champlain_layer_init (ChamplainLayer *self) +{ + g_signal_connect_after(G_OBJECT(self), "actor-added", G_CALLBACK(layer_add_cb), NULL); +} + /* This callback serves to keep the markers ordered by their latitude. * Markers that are up north on the map should be lowered in the list so that * they are drawn the first. This is to make the illusion of a semi-3d plane @@ -86,10 +166,5 @@ layer_add_cb (ClutterGroup *layer, ClutterActor *marker, gpointer data) ChamplainLayer * champlain_layer_new () { - ClutterActor *layer; - - layer = clutter_group_new(); - g_signal_connect_after(G_OBJECT(layer), "actor-added", G_CALLBACK(layer_add_cb), NULL); - - return layer; + return g_object_new (CHAMPLAIN_TYPE_LAYER, NULL); } diff --git a/champlain/champlain-layer.h b/champlain/champlain-layer.h index 7a30c89..6bd471a 100644 --- a/champlain/champlain-layer.h +++ b/champlain/champlain-layer.h @@ -28,8 +28,37 @@ #include #include -typedef ClutterActor ChamplainLayer; +G_BEGIN_DECLS -ChamplainLayer *champlain_layer_new (); +#define CHAMPLAIN_TYPE_LAYER champlain_layer_get_type() + +#define CHAMPLAIN_LAYER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_LAYER, ChamplainLayer)) + +#define CHAMPLAIN_LAYER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_LAYER, ChamplainLayerClass)) + +#define CHAMPLAIN_IS_LAYER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_LAYER)) + +#define CHAMPLAIN_IS_LAYER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_LAYER)) + +#define CHAMPLAIN_LAYER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_LAYER, ChamplainLayerClass)) + +typedef struct { + ClutterGroup parent; +} ChamplainLayer; + +typedef struct { + ClutterGroupClass parent_class; +} ChamplainLayerClass; + +GType champlain_layer_get_type (void); + +ChamplainLayer* champlain_layer_new (void); + +G_END_DECLS #endif