[libgdata] [calendar] Move initialisation code to constructor() in Calendar service
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] [calendar] Move initialisation code to constructor() in Calendar service
- Date: Wed, 11 Aug 2010 21:35:30 +0000 (UTC)
commit 20a2b4933fc823487949fe2fd5e59be3f195593a
Author: Philip Withnall <philip tecnocode co uk>
Date: Wed Aug 11 09:42:36 2010 +0100
[calendar] Move initialisation code to constructor() in Calendar service
Fix it in GDataCalendarCalendar and GDataCalendarEvent.
gdata/services/calendar/gdata-calendar-calendar.c | 29 ++++++++++++++++-----
gdata/services/calendar/gdata-calendar-event.c | 29 ++++++++++++++++-----
2 files changed, 44 insertions(+), 14 deletions(-)
---
diff --git a/gdata/services/calendar/gdata-calendar-calendar.c b/gdata/services/calendar/gdata-calendar-calendar.c
index 351a929..2b5708c 100644
--- a/gdata/services/calendar/gdata-calendar-calendar.c
+++ b/gdata/services/calendar/gdata-calendar-calendar.c
@@ -47,6 +47,7 @@
#include "gdata-access-handler.h"
static void gdata_calendar_calendar_access_handler_init (GDataAccessHandlerIface *iface);
+static GObject *gdata_calendar_calendar_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params);
static void gdata_calendar_calendar_finalize (GObject *object);
static void gdata_calendar_calendar_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_calendar_calendar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
@@ -87,6 +88,7 @@ gdata_calendar_calendar_class_init (GDataCalendarCalendarClass *klass)
g_type_class_add_private (klass, sizeof (GDataCalendarCalendarPrivate));
+ gobject_class->constructor = gdata_calendar_calendar_constructor;
gobject_class->set_property = gdata_calendar_calendar_set_property;
gobject_class->get_property = gdata_calendar_calendar_get_property;
gobject_class->finalize = gdata_calendar_calendar_finalize;
@@ -202,6 +204,25 @@ gdata_calendar_calendar_init (GDataCalendarCalendar *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_CALENDAR_CALENDAR, GDataCalendarCalendarPrivate);
}
+static GObject *
+gdata_calendar_calendar_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params)
+{
+ GObject *object;
+
+ /* Chain up to the parent class */
+ object = G_OBJECT_CLASS (gdata_calendar_calendar_parent_class)->constructor (type, n_construct_params, construct_params);
+
+ if (_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)) == FALSE) {
+ GDataCalendarCalendarPrivate *priv = GDATA_CALENDAR_CALENDAR (object)->priv;
+
+ /* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
+ * setting it from parse_xml() to fail (duplicate element). */
+ g_get_current_time (&(priv->edited));
+ }
+
+ return object;
+}
+
static void
gdata_calendar_calendar_finalize (GObject *object)
{
@@ -394,13 +415,7 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
GDataCalendarCalendar *
gdata_calendar_calendar_new (const gchar *id)
{
- GDataCalendarCalendar *calendar = GDATA_CALENDAR_CALENDAR (g_object_new (GDATA_TYPE_CALENDAR_CALENDAR, "id", id, NULL));
-
- /* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
- * setting it from parse_xml() to fail (duplicate element). */
- g_get_current_time (&(calendar->priv->edited));
-
- return calendar;
+ return GDATA_CALENDAR_CALENDAR (g_object_new (GDATA_TYPE_CALENDAR_CALENDAR, "id", id, NULL));
}
/**
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 1f2d82e..de93484 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -42,6 +42,7 @@
#include "gdata-types.h"
#include "gdata-comparable.h"
+static GObject *gdata_calendar_event_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params);
static void gdata_calendar_event_dispose (GObject *object);
static void gdata_calendar_event_finalize (GObject *object);
static void gdata_calendar_event_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
@@ -97,6 +98,7 @@ gdata_calendar_event_class_init (GDataCalendarEventClass *klass)
g_type_class_add_private (klass, sizeof (GDataCalendarEventPrivate));
+ gobject_class->constructor = gdata_calendar_event_constructor;
gobject_class->get_property = gdata_calendar_event_get_property;
gobject_class->set_property = gdata_calendar_event_set_property;
gobject_class->dispose = gdata_calendar_event_dispose;
@@ -294,6 +296,25 @@ gdata_calendar_event_init (GDataCalendarEvent *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_CALENDAR_EVENT, GDataCalendarEventPrivate);
}
+static GObject *
+gdata_calendar_event_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params)
+{
+ GObject *object;
+
+ /* Chain up to the parent class */
+ object = G_OBJECT_CLASS (gdata_calendar_event_parent_class)->constructor (type, n_construct_params, construct_params);
+
+ if (_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)) == FALSE) {
+ GDataCalendarEventPrivate *priv = GDATA_CALENDAR_EVENT (object)->priv;
+
+ /* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
+ * setting it from parse_xml() to fail (duplicate element). */
+ g_get_current_time (&(priv->edited));
+ }
+
+ return object;
+}
+
static void
gdata_calendar_event_dispose (GObject *object)
{
@@ -624,13 +645,7 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
GDataCalendarEvent *
gdata_calendar_event_new (const gchar *id)
{
- GDataCalendarEvent *event = GDATA_CALENDAR_EVENT (g_object_new (GDATA_TYPE_CALENDAR_EVENT, "id", id, NULL));
-
- /* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
- * setting it from parse_xml() to fail (duplicate element). */
- g_get_current_time (&(event->priv->edited));
-
- return event;
+ return GDATA_CALENDAR_EVENT (g_object_new (GDATA_TYPE_CALENDAR_EVENT, "id", id, NULL));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]