[gnome-panel] clock: avoid deprecated g_type_class_add_private



commit 3387df20161ed9cde1b77de1e8c0dea7ae01c00f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Sep 11 14:21:53 2018 +0300

    clock: avoid deprecated g_type_class_add_private

 modules/clock/calendar-client.c     | 42 ++---------------
 modules/clock/calendar-sources.c    | 42 ++---------------
 modules/clock/calendar-window.c     |  8 +---
 modules/clock/clock-face.c          |  8 ++--
 modules/clock/clock-location-tile.c | 58 +++++++++++++-----------
 modules/clock/clock-location-tile.h |  4 ++
 modules/clock/clock-location.c      | 89 ++++++++++++++++---------------------
 modules/clock/clock-location.h      |  4 ++
 modules/clock/clock-map.c           | 58 ++++++++++++++----------
 modules/clock/clock-map.h           |  4 ++
 modules/clock/system-timezone.c     | 41 +++++++++--------
 modules/clock/system-timezone.h     |  4 ++
 12 files changed, 154 insertions(+), 208 deletions(-)
---
diff --git a/modules/clock/calendar-client.c b/modules/clock/calendar-client.c
index 7c6b87ac4..b88cffd44 100644
--- a/modules/clock/calendar-client.c
+++ b/modules/clock/calendar-client.c
@@ -43,8 +43,6 @@
 #define N_(x) x
 #endif
 
-#define CALENDAR_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_CLIENT, 
CalendarClientPrivate))
-
 typedef struct _CalendarClientQuery  CalendarClientQuery;
 typedef struct _CalendarClientSource CalendarClientSource;
 
@@ -85,8 +83,6 @@ struct _CalendarClientPrivate
   guint                year;
 };
 
-static void calendar_client_class_init   (CalendarClientClass *klass);
-static void calendar_client_init         (CalendarClient      *client);
 static void calendar_client_finalize     (GObject             *object);
 static void calendar_client_set_property (GObject             *object,
                                          guint                prop_id,
@@ -134,50 +130,19 @@ enum
   LAST_SIGNAL
 };
 
-static GObjectClass *parent_class = NULL;
 static guint         signals [LAST_SIGNAL] = { 0, };
 
-GType
-calendar_client_get_type (void)
-{
-  static GType client_type = 0;
-  
-  if (!client_type)
-    {
-      static const GTypeInfo client_info =
-      {
-       sizeof (CalendarClientClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) calendar_client_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (CalendarClient),
-       0,              /* n_preallocs */
-       (GInstanceInitFunc) calendar_client_init,
-      };
-      
-      client_type = g_type_register_static (G_TYPE_OBJECT,
-                                           "CalendarClient",
-                                           &client_info, 0);
-    }
-  
-  return client_type;
-}
+G_DEFINE_TYPE_WITH_PRIVATE (CalendarClient, calendar_client, G_TYPE_OBJECT)
 
 static void
 calendar_client_class_init (CalendarClientClass *klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->finalize     = calendar_client_finalize;
   gobject_class->set_property = calendar_client_set_property;
   gobject_class->get_property = calendar_client_get_property;
 
-  g_type_class_add_private (klass, sizeof (CalendarClientPrivate));
-
   g_object_class_install_property (gobject_class,
                                   PROP_DAY,
                                   g_param_spec_uint ("day",
@@ -359,7 +324,7 @@ calendar_client_init (CalendarClient *client)
   GSettingsSchemaSource *schema_source;
   const gchar *evolution_calendar_schema;
 
-  client->priv = CALENDAR_CLIENT_GET_PRIVATE (client);
+  client->priv = calendar_client_get_instance_private (client);
 
   client->priv->calendar_sources = calendar_sources_get ();
 
@@ -440,8 +405,7 @@ calendar_client_finalize (GObject *object)
     g_object_unref (client->priv->calendar_sources);
   client->priv->calendar_sources = NULL;
 
-  if (G_OBJECT_CLASS (parent_class)->finalize)
-    G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (calendar_client_parent_class)->finalize (object);
 }
 
 static void
diff --git a/modules/clock/calendar-sources.c b/modules/clock/calendar-sources.c
index e980bb611..8973a66e9 100644
--- a/modules/clock/calendar-sources.c
+++ b/modules/clock/calendar-sources.c
@@ -41,8 +41,6 @@
 #define N_(x) x
 #endif
 
-#define CALENDAR_SOURCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_SOURCES, 
CalendarSourcesPrivate))
-
 typedef struct _ClientData ClientData;
 typedef struct _CalendarSourceData CalendarSourceData;
 
@@ -77,8 +75,6 @@ struct _CalendarSourcesPrivate
   CalendarSourceData  task_sources;
 };
 
-static void calendar_sources_class_init (CalendarSourcesClass *klass);
-static void calendar_sources_init       (CalendarSources      *sources);
 static void calendar_sources_finalize   (GObject             *object);
 
 static void backend_died_cb (ECal *client, CalendarSourceData *source_data);
@@ -97,7 +93,6 @@ enum
 };
 static guint signals [LAST_SIGNAL] = { 0, };
 
-static GObjectClass    *parent_class = NULL;
 static CalendarSources *calendar_sources_singleton = NULL;
 
 static void
@@ -108,45 +103,15 @@ client_data_free (ClientData *data)
   g_slice_free (ClientData, data);
 }
 
-GType
-calendar_sources_get_type (void)
-{
-  static GType sources_type = 0;
-  
-  if (!sources_type)
-    {
-      static const GTypeInfo sources_info =
-      {
-       sizeof (CalendarSourcesClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) calendar_sources_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (CalendarSources),
-       0,              /* n_preallocs */
-       (GInstanceInitFunc) calendar_sources_init,
-      };
-      
-      sources_type = g_type_register_static (G_TYPE_OBJECT,
-                                            "CalendarSources",
-                                            &sources_info, 0);
-    }
-  
-  return sources_type;
-}
+G_DEFINE_TYPE_WITH_PRIVATE (CalendarSources, calendar_sources, G_TYPE_OBJECT)
 
 static void
 calendar_sources_class_init (CalendarSourcesClass *klass)
 {
   GObjectClass *gobject_class = (GObjectClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->finalize = calendar_sources_finalize;
 
-  g_type_class_add_private (klass, sizeof (CalendarSourcesPrivate));
-
   signals [APPOINTMENT_SOURCES_CHANGED] =
     g_signal_new ("appointment-sources-changed",
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -177,7 +142,7 @@ calendar_sources_init (CalendarSources *sources)
 {
   GError *error = NULL;
 
-  sources->priv = CALENDAR_SOURCES_GET_PRIVATE (sources);
+  sources->priv = calendar_sources_get_instance_private (sources);
 
   /* XXX Not sure what to do if this fails.
    *     Should this class implement GInitable or pass the
@@ -259,8 +224,7 @@ calendar_sources_finalize (GObject *object)
   calendar_sources_finalize_source_data (sources, &sources->priv->appointment_sources);
   calendar_sources_finalize_source_data (sources, &sources->priv->task_sources);
 
-  if (G_OBJECT_CLASS (parent_class)->finalize)
-    G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (calendar_sources_parent_class)->finalize (object);
 }
 
 CalendarSources *
diff --git a/modules/clock/calendar-window.c b/modules/clock/calendar-window.c
index 0941cc177..05cc988a5 100644
--- a/modules/clock/calendar-window.c
+++ b/modules/clock/calendar-window.c
@@ -49,8 +49,6 @@
 #include "calendar-client.h"
 #endif
 
-#define CALENDAR_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_WINDOW, 
CalendarWindowPrivate))
-
 #define KEY_LOCATIONS_EXPANDED      "expand-locations"
 #ifdef HAVE_EDS
 #  define KEY_APPOINTMENTS_EXPANDED "expand-appointments"
@@ -103,7 +101,7 @@ struct _CalendarWindowPrivate {
 #endif /* HAVE_EDS */
 };
 
-G_DEFINE_TYPE (CalendarWindow, calendar_window, GTK_TYPE_WINDOW)
+G_DEFINE_TYPE_WITH_PRIVATE (CalendarWindow, calendar_window, GTK_TYPE_WINDOW)
 
 enum {
        PROP_0,
@@ -1759,8 +1757,6 @@ calendar_window_class_init (CalendarWindowClass *klass)
         gobject_class->set_property = calendar_window_set_property;
        gobject_class->dispose = calendar_window_dispose;
 
-       g_type_class_add_private (klass, sizeof (CalendarWindowPrivate));
-
        signals[EDIT_LOCATIONS] = g_signal_new ("edit-locations",
                                                G_TYPE_FROM_CLASS (gobject_class),
                                                G_SIGNAL_RUN_FIRST,
@@ -1814,7 +1810,7 @@ calendar_window_init (CalendarWindow *calwin)
 {
        GtkWindow *window;
 
-       calwin->priv = CALENDAR_WINDOW_GET_PRIVATE (calwin);
+       calwin->priv = calendar_window_get_instance_private (calwin);
 
        window = GTK_WINDOW (calwin);
        gtk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_DOCK);
diff --git a/modules/clock/clock-face.c b/modules/clock/clock-face.c
index f65bf0669..1f6057324 100644
--- a/modules/clock/clock-face.c
+++ b/modules/clock/clock-face.c
@@ -22,8 +22,6 @@
 
 static GHashTable *pixbuf_cache = NULL;
 
-G_DEFINE_TYPE (ClockFace, clock_face, GTK_TYPE_WIDGET)
-
 static void     clock_face_finalize             (GObject *);
 static gboolean clock_face_draw                 (GtkWidget     *clock,
                                                  cairo_t       *cr);
@@ -61,6 +59,8 @@ struct _ClockFacePrivate
         GtkWidget *size_widget;
 };
 
+G_DEFINE_TYPE_WITH_PRIVATE (ClockFace, clock_face, GTK_TYPE_WIDGET)
+
 static void
 clock_face_class_init (ClockFaceClass *class)
 {
@@ -78,8 +78,6 @@ clock_face_class_init (ClockFaceClass *class)
 
         /* GObject signals */
         obj_class->finalize = clock_face_finalize;
-
-        g_type_class_add_private (obj_class, sizeof (ClockFacePrivate));
 }
 
 static void
@@ -87,7 +85,7 @@ clock_face_init (ClockFace *this)
 {
         ClockFacePrivate *priv;
 
-        priv = this->priv = G_TYPE_INSTANCE_GET_PRIVATE (this, INTL_TYPE_CLOCK_FACE, ClockFacePrivate);
+        priv = this->priv = clock_face_get_instance_private (this);
 
         priv->size = CLOCK_FACE_SMALL;
         priv->timeofday = CLOCK_FACE_INVALID;
diff --git a/modules/clock/clock-location-tile.c b/modules/clock/clock-location-tile.c
index 8016052b1..6aaabc34e 100644
--- a/modules/clock/clock-location-tile.c
+++ b/modules/clock/clock-location-tile.c
@@ -15,8 +15,6 @@
 #include "clock-utils.h"
 #include "set-timezone.h"
 
-G_DEFINE_TYPE (ClockLocationTile, clock_location_tile, GTK_TYPE_BIN)
-
 enum {
        TILE_PRESSED,
        NEED_CLOCK_FORMAT,
@@ -25,7 +23,7 @@ enum {
 
 static guint signals[LAST_SIGNAL];
 
-typedef struct {
+struct _ClockLocationTilePrivate {
         ClockLocation *location;
 
         GDateTime *last_refresh;
@@ -46,11 +44,11 @@ typedef struct {
         GtkWidget *weather_icon;
 
        gulong location_weather_updated_id;
-} ClockLocationTilePrivate;
+};
 
-static void clock_location_tile_finalize (GObject *);
+G_DEFINE_TYPE_WITH_PRIVATE (ClockLocationTile, clock_location_tile, GTK_TYPE_BIN)
 
-#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CLOCK_LOCATION_TILE_TYPE, ClockLocationTilePrivate))
+static void clock_location_tile_finalize (GObject *);
 
 static void clock_location_tile_fill (ClockLocationTile *this);
 static void update_weather_icon (ClockLocation *loc, GWeatherInfo *info, gpointer data);
@@ -68,7 +66,7 @@ clock_location_tile_new (ClockLocation *loc,
         ClockLocationTilePrivate *priv;
 
         this = g_object_new (CLOCK_LOCATION_TILE_TYPE, NULL);
-        priv = PRIVATE (this);
+        priv = this->priv;
 
         priv->location = g_object_ref (loc);
         priv->size = size;
@@ -93,8 +91,6 @@ clock_location_tile_class_init (ClockLocationTileClass *this_class)
 
         g_obj_class->finalize = clock_location_tile_finalize;
 
-        g_type_class_add_private (this_class, sizeof (ClockLocationTilePrivate));
-
        signals[TILE_PRESSED] = g_signal_new ("tile-pressed",
                                              G_TYPE_FROM_CLASS (g_obj_class),
                                              G_SIGNAL_RUN_FIRST,
@@ -116,7 +112,10 @@ clock_location_tile_class_init (ClockLocationTileClass *this_class)
 static void
 clock_location_tile_init (ClockLocationTile *this)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (this);
+        ClockLocationTilePrivate *priv;
+
+        this->priv = clock_location_tile_get_instance_private (this);
+        priv = this->priv;
 
         priv->location = NULL;
 
@@ -133,7 +132,11 @@ clock_location_tile_init (ClockLocationTile *this)
 static void
 clock_location_tile_finalize (GObject *g_obj)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (g_obj);
+        ClockLocationTile *tile;
+        ClockLocationTilePrivate *priv;
+
+        tile = CLOCK_LOCATION_TILE (g_obj);
+        priv = tile->priv;
 
        if (priv->last_refresh) {
                g_date_time_unref (priv->last_refresh);
@@ -184,9 +187,7 @@ make_current_cb (gpointer data, GError *error)
 static void
 make_current (GtkWidget *widget, ClockLocationTile *tile)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (tile);
-
-       clock_location_make_current (priv->location,
+       clock_location_make_current (tile->priv->location,
                                     (GFunc)make_current_cb, tile, NULL);
 }
 
@@ -195,7 +196,9 @@ enter_or_leave_tile (GtkWidget             *widget,
                      GdkEventCrossing      *event,
                      ClockLocationTile *tile)
 {
-       ClockLocationTilePrivate *priv = PRIVATE (tile);
+       ClockLocationTilePrivate *priv;
+
+       priv = tile->priv;
 
        if (event->mode != GDK_CROSSING_NORMAL) {
                return TRUE;
@@ -245,7 +248,7 @@ enter_or_leave_tile (GtkWidget             *widget,
 static void
 clock_location_tile_fill (ClockLocationTile *this)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (this);
+        ClockLocationTilePrivate *priv;
         GtkWidget *strut;
         GtkWidget *box;
         GtkWidget *tile;
@@ -253,6 +256,7 @@ clock_location_tile_fill (ClockLocationTile *this)
         GtkSizeGroup *current_group;
         GtkSizeGroup *button_group;
 
+        priv = this->priv;
         priv->box = gtk_event_box_new ();
 
         gtk_widget_add_events (priv->box, GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | 
GDK_LEAVE_NOTIFY_MASK);
@@ -349,10 +353,12 @@ clock_location_tile_fill (ClockLocationTile *this)
 static gboolean
 clock_needs_face_refresh (ClockLocationTile *this)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (this);
+        ClockLocationTilePrivate *priv;
         GDateTime *now;
        gboolean retval;
 
+       priv = this->priv;
+
        if (!priv->last_refresh)
                return TRUE;
 
@@ -379,11 +385,13 @@ clock_needs_face_refresh (ClockLocationTile *this)
 static gboolean
 clock_needs_label_refresh (ClockLocationTile *this)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (this);
+        ClockLocationTilePrivate *priv;
        GDateTime *now;
        long offset;
        gboolean retval;
 
+       priv = this->priv;
+
        if (!priv->last_refresh)
                return TRUE;
 
@@ -514,7 +522,7 @@ convert_time_to_str (time_t now, GDesktopClockFormat clock_format, const char *t
 void
 clock_location_tile_refresh (ClockLocationTile *this, gboolean force_refresh)
 {
-        ClockLocationTilePrivate *priv = PRIVATE (this);
+        ClockLocationTilePrivate *priv;
         gchar *tmp;
        const char *tzname;
        GDateTime *now;
@@ -523,6 +531,8 @@ clock_location_tile_refresh (ClockLocationTile *this, gboolean force_refresh)
 
        g_return_if_fail (IS_CLOCK_LOCATION_TILE (this));
 
+       priv = this->priv;
+
         if (clock_location_is_current (priv->location)) {
                gtk_widget_hide (priv->current_spacer);
                gtk_widget_hide (priv->current_button);
@@ -651,7 +661,7 @@ weather_tooltip (GtkWidget  *widget,
                 gpointer    data)
 {
         ClockLocationTile *tile = data;
-        ClockLocationTilePrivate *priv = PRIVATE (tile);
+        ClockLocationTilePrivate *priv = tile->priv;
        GWeatherInfo *info;
        int clock_format;
 
@@ -671,7 +681,7 @@ static void
 update_weather_icon (ClockLocation *loc, GWeatherInfo *info, gpointer data)
 {
         ClockLocationTile *tile = data;
-        ClockLocationTilePrivate *priv = PRIVATE (tile);
+        ClockLocationTilePrivate *priv = tile->priv;
         GdkPixbuf *pixbuf = NULL;
         GtkIconTheme *theme = NULL;
         const gchar *icon_name;
@@ -693,11 +703,7 @@ update_weather_icon (ClockLocation *loc, GWeatherInfo *info, gpointer data)
 ClockLocation *
 clock_location_tile_get_location (ClockLocationTile *this)
 {
-        ClockLocationTilePrivate *priv;
-
        g_return_val_if_fail (IS_CLOCK_LOCATION_TILE (this), NULL);
 
-       priv = PRIVATE (this);
-
-       return g_object_ref (priv->location);
+       return g_object_ref (this->priv->location);
 }
diff --git a/modules/clock/clock-location-tile.h b/modules/clock/clock-location-tile.h
index ab622e439..d130ad2c2 100644
--- a/modules/clock/clock-location-tile.h
+++ b/modules/clock/clock-location-tile.h
@@ -16,9 +16,13 @@ G_BEGIN_DECLS
 #define IS_CLOCK_LOCATION_TILE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), CLOCK_LOCATION_TILE_TYPE))
 #define CLOCK_LOCATION_TILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CLOCK_LOCATION_TILE_TYPE, 
ClockLocationTileClass))
 
+typedef struct _ClockLocationTilePrivate ClockLocationTilePrivate;
+
 typedef struct
 {
         GtkBin parent;
+
+        ClockLocationTilePrivate *priv;
 } ClockLocationTile;
 
 typedef struct
diff --git a/modules/clock/clock-location.c b/modules/clock/clock-location.c
index 25bfc030b..ae6560de7 100644
--- a/modules/clock/clock-location.c
+++ b/modules/clock/clock-location.c
@@ -20,9 +20,7 @@
 #include "set-timezone.h"
 #include "system-timezone.h"
 
-G_DEFINE_TYPE (ClockLocation, clock_location, G_TYPE_OBJECT)
-
-typedef struct {
+struct _ClockLocationPrivate {
         gchar *name;
 
        GWeatherLocation *world;
@@ -36,7 +34,9 @@ typedef struct {
         GWeatherInfo *weather_info;
        gint          weather_timeout;
        gint          weather_retry_time;
-} ClockLocationPrivate;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (ClockLocation, clock_location, G_TYPE_OBJECT)
 
 #define WEATHER_TIMEOUT_BASE 30
 #define WEATHER_TIMEOUT_MAX  1800
@@ -54,8 +54,6 @@ static void clock_location_finalize (GObject *);
 static gboolean update_weather_info (gpointer user_data);
 static void setup_weather_updates (ClockLocation *loc);
 
-#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CLOCK_LOCATION_TYPE, ClockLocationPrivate))
-
 ClockLocation *
 clock_location_new (GWeatherLocation *world,
                    const char       *name,
@@ -68,7 +66,7 @@ clock_location_new (GWeatherLocation *world,
         ClockLocationPrivate *priv;
 
         this = g_object_new (CLOCK_LOCATION_TYPE, NULL);
-        priv = PRIVATE (this);
+        priv = this->priv;
 
        priv->world = gweather_location_ref (world);
        priv->loc = gweather_location_find_by_station_code (priv->world,
@@ -118,8 +116,6 @@ clock_location_class_init (ClockLocationClass *this_class)
                              NULL, NULL,
                              NULL,
                              G_TYPE_NONE, 0);
-
-        g_type_class_add_private (this_class, sizeof (ClockLocationPrivate));
 }
 
 static void
@@ -127,10 +123,8 @@ network_changed (GNetworkMonitor *monitor,
                  gboolean         available,
                  ClockLocation   *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
-
         if (available) {
-                priv->weather_retry_time = WEATHER_TIMEOUT_BASE;
+                loc->priv->weather_retry_time = WEATHER_TIMEOUT_BASE;
                 update_weather_info (loc);
         }
 }
@@ -138,9 +132,10 @@ network_changed (GNetworkMonitor *monitor,
 static void
 clock_location_init (ClockLocation *this)
 {
-        ClockLocationPrivate *priv = PRIVATE (this);
+        ClockLocationPrivate *priv;
         GNetworkMonitor *monitor;
 
+        priv = this->priv = clock_location_get_instance_private (this);
         priv->systz = system_timezone_new ();
 
         priv->latitude = 0;
@@ -154,9 +149,13 @@ clock_location_init (ClockLocation *this)
 static void
 clock_location_finalize (GObject *g_obj)
 {
-        ClockLocationPrivate *priv = PRIVATE (g_obj);
+        ClockLocation *loc;
+        ClockLocationPrivate *priv;
         GNetworkMonitor *monitor;
 
+        loc = CLOCK_LOCATION (g_obj);
+        priv = loc->priv;
+
        monitor = g_network_monitor_get_default ();
        g_signal_handlers_disconnect_by_func (monitor,
                                              G_CALLBACK (network_changed),
@@ -186,15 +185,15 @@ clock_location_finalize (GObject *g_obj)
 const gchar *
 clock_location_get_name (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
-
-        return priv->name;
+        return loc->priv->name;
 }
 
 void
 clock_location_set_name (ClockLocation *loc, const gchar *name)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
+        ClockLocationPrivate *priv;
+
+        priv = loc->priv;
 
         if (priv->name) {
                 g_free (priv->name);
@@ -207,28 +206,24 @@ clock_location_set_name (ClockLocation *loc, const gchar *name)
 gchar *
 clock_location_get_city (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
-
-        return gweather_location_get_city_name (priv->loc);
+        return gweather_location_get_city_name (loc->priv->loc);
 }
 
 const gchar *
 clock_location_get_timezone (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
        GWeatherTimezone *tz;
 
-       tz = gweather_location_get_timezone (priv->loc);
+       tz = gweather_location_get_timezone (loc->priv->loc);
         return gweather_timezone_get_name (tz);
 }
 
 const gchar *
 clock_location_get_tzname (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
        GWeatherTimezone *tz;
 
-       tz = gweather_location_get_timezone (priv->loc);
+       tz = gweather_location_get_timezone (loc->priv->loc);
         return gweather_timezone_get_tzid (tz);
 }
 
@@ -237,21 +232,18 @@ clock_location_get_coords (ClockLocation *loc,
                           gdouble *latitude,
                           gdouble *longitude)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
-
-        *latitude = priv->latitude;
-        *longitude = priv->longitude;
+        *latitude = loc->priv->latitude;
+        *longitude = loc->priv->longitude;
 }
 
 GDateTime *
 clock_location_localtime (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
        GWeatherTimezone *wtz;
        GTimeZone *tz;
        GDateTime *dt;
 
-       wtz = gweather_location_get_timezone (priv->loc);
+       wtz = gweather_location_get_timezone (loc->priv->loc);
 
        tz = g_time_zone_new (gweather_timezone_get_tzid (wtz));
        dt = g_date_time_new_now (tz);
@@ -263,13 +255,12 @@ clock_location_localtime (ClockLocation *loc)
 gboolean
 clock_location_is_current_timezone (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
        GWeatherTimezone *wtz;
        const char *zone;
 
-       wtz = gweather_location_get_timezone (priv->loc);
+       wtz = gweather_location_get_timezone (loc->priv->loc);
 
-       zone = system_timezone_get (priv->systz);
+       zone = system_timezone_get (loc->priv->systz);
 
        if (zone)
                return strcmp (zone, gweather_timezone_get_tzid (wtz)) == 0;
@@ -305,10 +296,9 @@ clock_location_is_current (ClockLocation *loc)
 glong
 clock_location_get_offset (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
        GWeatherTimezone *wtz;
 
-       wtz = gweather_location_get_timezone (priv->loc);
+       wtz = gweather_location_get_timezone (loc->priv->loc);
        return gweather_timezone_get_offset (wtz);
 }
 
@@ -358,7 +348,6 @@ clock_location_make_current (ClockLocation *loc,
                              gpointer       data,
                              GDestroyNotify destroy)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
        MakeCurrentData *mcdata;
        GWeatherTimezone *wtz;
 
@@ -391,7 +380,7 @@ clock_location_make_current (ClockLocation *loc,
        mcdata->data = data;
        mcdata->destroy = destroy;
 
-       wtz = gweather_location_get_timezone (priv->loc);
+       wtz = gweather_location_get_timezone (loc->priv->loc);
         set_system_timezone_async (gweather_timezone_get_tzid (wtz),
                                    make_current_cb,
                                    mcdata);
@@ -400,25 +389,23 @@ clock_location_make_current (ClockLocation *loc,
 const gchar *
 clock_location_get_weather_code (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
-
-       return gweather_location_get_code (priv->loc);
+       return gweather_location_get_code (loc->priv->loc);
 }
 
 GWeatherInfo *
 clock_location_get_weather_info (ClockLocation *loc)
 {
-        ClockLocationPrivate *priv = PRIVATE (loc);
-
-       return priv->weather_info;
+       return loc->priv->weather_info;
 }
 
 static void
 set_weather_update_timeout (ClockLocation *loc)
 {
-       ClockLocationPrivate *priv = PRIVATE (loc);
+       ClockLocationPrivate *priv;
        guint timeout;
 
+       priv = loc->priv;
+
        if (!gweather_info_network_error (priv->weather_info)) {
                /* The last update succeeded; set the next update to
                 * happen in half an hour, and reset the retry timer.
@@ -446,21 +433,19 @@ static void
 weather_info_updated (GWeatherInfo *info, gpointer data)
 {
        ClockLocation *loc = data;
-       ClockLocationPrivate *priv = PRIVATE (loc);
 
        set_weather_update_timeout (loc);
        g_signal_emit (loc, location_signals[WEATHER_UPDATED],
-                      0, priv->weather_info);
+                      0, loc->priv->weather_info);
 }
 
 static gboolean
 update_weather_info (gpointer user_data)
 {
        ClockLocation *loc = user_data;
-       ClockLocationPrivate *priv = PRIVATE (loc);
 
-       gweather_info_abort (priv->weather_info);
-        gweather_info_update (priv->weather_info);
+       gweather_info_abort (loc->priv->weather_info);
+       gweather_info_update (loc->priv->weather_info);
 
        return TRUE;
 }
@@ -468,7 +453,9 @@ update_weather_info (gpointer user_data)
 static void
 setup_weather_updates (ClockLocation *loc)
 {
-       ClockLocationPrivate *priv = PRIVATE (loc);
+       ClockLocationPrivate *priv;
+
+       priv = loc->priv;
 
        g_clear_object (&priv->weather_info);
 
diff --git a/modules/clock/clock-location.h b/modules/clock/clock-location.h
index ecd90d2bc..345fe0afa 100644
--- a/modules/clock/clock-location.h
+++ b/modules/clock/clock-location.h
@@ -15,9 +15,13 @@ G_BEGIN_DECLS
 #define IS_CLOCK_LOCATION_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), CLOCK_LOCATION_TYPE))
 #define CLOCK_LOCATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CLOCK_LOCATION_TYPE, 
ClockLocationClass))
 
+typedef struct _ClockLocationPrivate ClockLocationPrivate;
+
 typedef struct
 {
         GObject g_object;
+
+        ClockLocationPrivate *priv;
 } ClockLocation;
 
 typedef struct
diff --git a/modules/clock/clock-map.c b/modules/clock/clock-map.c
index 47d79894d..622b4256a 100644
--- a/modules/clock/clock-map.c
+++ b/modules/clock/clock-map.c
@@ -12,8 +12,6 @@
 #include "clock-map.h"
 #include "clock-sunpos.h"
 
-G_DEFINE_TYPE (ClockMap, clock_map, GTK_TYPE_WIDGET)
-
 enum {
        NEED_LOCATIONS,
        LAST_SIGNAL
@@ -34,7 +32,7 @@ static const gchar *marker_files[MARKER_NB] = {
 
 static guint signals[LAST_SIGNAL];
 
-typedef struct {
+struct _ClockMapPrivate {
         time_t last_refresh;
 
         gint width;
@@ -52,7 +50,9 @@ typedef struct {
 
         /* The map with the shadow composited onto it */
         GdkPixbuf *shadow_map_pixbuf;
-} ClockMapPrivate;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (ClockMap, clock_map, GTK_TYPE_WIDGET)
 
 static void     clock_map_finalize             (GObject *);
 static void     clock_map_get_preferred_width  (GtkWidget     *this,
@@ -70,8 +70,6 @@ static void clock_map_place_locations (ClockMap *this);
 static void clock_map_render_shadow (ClockMap *this);
 static void clock_map_display (ClockMap *this);
 
-#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CLOCK_MAP_TYPE, ClockMapPrivate))
-
 static void
 rgb_to_hls (gdouble *r, gdouble *g, gdouble *b)
 {
@@ -267,8 +265,6 @@ clock_map_class_init (ClockMapClass *this_class)
         widget_class->size_allocate = clock_map_size_allocate;
        widget_class->draw = clock_map_draw;
 
-        g_type_class_add_private (this_class, sizeof (ClockMapPrivate));
-
        /**
         * ClockMap::need-locations
         *
@@ -293,7 +289,10 @@ static void
 clock_map_init (ClockMap *this)
 {
         int i;
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMapPrivate *priv;
+
+        this->priv = clock_map_get_instance_private (this);
+        priv = this->priv;
 
         gtk_widget_set_has_window (GTK_WIDGET (this), FALSE);
 
@@ -317,9 +316,13 @@ clock_map_init (ClockMap *this)
 static void
 clock_map_finalize (GObject *g_obj)
 {
-        ClockMapPrivate *priv = PRIVATE (g_obj);
+        ClockMap *map;
+        ClockMapPrivate *priv;
        int i;
 
+       map = CLOCK_MAP (g_obj);
+       priv = map->priv;
+
        if (priv->highlight_timeout_id) {
                g_source_remove (priv->highlight_timeout_id);
                priv->highlight_timeout_id = 0;
@@ -358,7 +361,7 @@ clock_map_finalize (GObject *g_obj)
 void
 clock_map_refresh (ClockMap *this)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMapPrivate *priv = this->priv;
        GtkWidget *widget = GTK_WIDGET (this);
        GtkAllocation allocation;
 
@@ -396,11 +399,15 @@ clock_map_refresh (ClockMap *this)
 static gboolean
 clock_map_draw (GtkWidget *this, cairo_t *cr)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMap *map;
+        ClockMapPrivate *priv;
         GtkStyleContext *context;
         GdkRGBA  color;
         int width, height;
 
+        map = CLOCK_MAP (this);
+        priv = map->priv;
+
         context = gtk_widget_get_style_context (this);
         gtk_style_context_get_color (context, GTK_STATE_FLAG_ACTIVE, &color);
 
@@ -447,7 +454,11 @@ clock_map_get_preferred_height (GtkWidget *this,
 static void
 clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMap *map;
+        ClockMapPrivate *priv;
+
+        map = CLOCK_MAP (this);
+        priv = map->priv;
 
        if (GTK_WIDGET_CLASS (clock_map_parent_class)->size_allocate)
                GTK_WIDGET_CLASS (clock_map_parent_class)->size_allocate (this, allocation);
@@ -463,7 +474,7 @@ clock_map_mark (ClockMap *this,
                 gdouble   longitude,
                 gint      mark)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMapPrivate *priv = this->priv;
         GdkPixbuf *marker = priv->location_marker_pixbuf[mark];
         GdkPixbuf *partial = NULL;
 
@@ -608,7 +619,7 @@ clock_map_place_location (ClockMap *this, ClockLocation *loc, gboolean hilight)
 static void
 clock_map_place_locations (ClockMap *this)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMapPrivate *priv = this->priv;
         GList *locs;
         ClockLocation *loc;
 
@@ -735,7 +746,9 @@ clock_map_render_shadow_pixbuf (GdkPixbuf *pixbuf)
 static void
 clock_map_render_shadow (ClockMap *this)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMapPrivate *priv;
+
+        priv = this->priv;
 
         if (priv->shadow_pixbuf) {
                 g_object_unref (priv->shadow_pixbuf);
@@ -763,7 +776,9 @@ clock_map_render_shadow (ClockMap *this)
 static void
 clock_map_display (ClockMap *this)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
+        ClockMapPrivate *priv;
+
+        priv = this->priv;
 
         if (priv->width > 0 || priv->height > 0)
                 clock_map_render_shadow (this);
@@ -803,10 +818,8 @@ static void
 highlight_destroy (gpointer user_data)
 {
        BlinkData *data = user_data;
-       ClockMapPrivate *priv;
 
-       priv = PRIVATE (data->map);
-       priv->highlight_timeout_id = 0;
+       data->map->priv->highlight_timeout_id = 0;
 
        g_object_unref (data->location);
        g_free (data);
@@ -818,7 +831,7 @@ clock_map_blink_location (ClockMap *this, ClockLocation *loc)
        BlinkData *data;
        ClockMapPrivate *priv;
 
-       priv = PRIVATE (this);
+       priv = this->priv;
 
        g_return_if_fail (IS_CLOCK_MAP (this));
        g_return_if_fail (IS_CLOCK_LOCATION (loc));
@@ -842,13 +855,12 @@ clock_map_blink_location (ClockMap *this, ClockLocation *loc)
 static gboolean
 clock_map_needs_refresh (ClockMap *this)
 {
-        ClockMapPrivate *priv = PRIVATE (this);
         time_t now_t;
 
         time (&now_t);
 
        /* refresh once per minute */
-       return (ABS (now_t - priv->last_refresh) >= 60);
+       return (ABS (now_t - this->priv->last_refresh) >= 60);
 }
 
 void
diff --git a/modules/clock/clock-map.h b/modules/clock/clock-map.h
index 1f176065c..7ff468346 100644
--- a/modules/clock/clock-map.h
+++ b/modules/clock/clock-map.h
@@ -14,9 +14,13 @@ G_BEGIN_DECLS
 #define IS_CLOCK_MAP_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), CLOCK_MAP_TYPE))
 #define CLOCK_MAP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CLOCK_MAP_TYPE, ClockMapClass))
 
+typedef struct _ClockMapPrivate ClockMapPrivate;
+
 typedef struct
 {
         GtkWidget parent;
+
+        ClockMapPrivate *priv;
 } ClockMap;
 
 typedef struct
diff --git a/modules/clock/system-timezone.c b/modules/clock/system-timezone.c
index 04b65280d..0a5cdc597 100644
--- a/modules/clock/system-timezone.c
+++ b/modules/clock/system-timezone.c
@@ -80,12 +80,12 @@ static const gchar *files_to_check[CHECK_NB] = {
 
 static GObject *systz_singleton = NULL;
 
-G_DEFINE_TYPE (SystemTimezone, system_timezone, G_TYPE_OBJECT)
-
-typedef struct {
+struct _SystemTimezonePrivate {
         char *tz;
         GFileMonitor *monitors[CHECK_NB];
-} SystemTimezonePrivate;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (SystemTimezone, system_timezone, G_TYPE_OBJECT)
 
 static GObject *system_timezone_constructor (GType                  type,
                                              guint                  n_construct_properties,
@@ -99,8 +99,6 @@ static void system_timezone_monitor_changed (GFileMonitor *handle,
                                              gpointer user_data);
 static char *system_timezone_find (void);
 
-#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SYSTEM_TIMEZONE_TYPE, SystemTimezonePrivate))
-
 SystemTimezone *
 system_timezone_new (void)
 {
@@ -110,12 +108,9 @@ system_timezone_new (void)
 const char *
 system_timezone_get (SystemTimezone *systz)
 {
-        SystemTimezonePrivate *priv;
-
         g_return_val_if_fail (IS_SYSTEM_TIMEZONE (systz), NULL);
 
-        priv = PRIVATE (systz);
-        return priv->tz;
+        return systz->priv->tz;
 }
 
 static void
@@ -125,19 +120,18 @@ system_timezone_class_init (SystemTimezoneClass *class)
 
         g_obj_class->constructor = system_timezone_constructor;
         g_obj_class->finalize = system_timezone_finalize;
-
-        g_type_class_add_private (class, sizeof (SystemTimezonePrivate));
 }
 
 static void
 system_timezone_init (SystemTimezone *systz)
 {
         int i;
-        SystemTimezonePrivate *priv = PRIVATE (systz);
 
-        priv->tz = NULL;
+        systz->priv = system_timezone_get_instance_private (systz);
+
+        systz->priv->tz = NULL;
         for (i = 0; i < CHECK_NB; i++) 
-                priv->monitors[i] = NULL;
+                systz->priv->monitors[i] = NULL;
 }
 
 static GObject *
@@ -146,6 +140,7 @@ system_timezone_constructor (GType                  type,
                              GObjectConstructParam *construct_properties)
 {
         GObject *obj;
+        SystemTimezone *systz;
         SystemTimezonePrivate *priv;
         int i;
 
@@ -158,7 +153,8 @@ system_timezone_constructor (GType                  type,
                                                 n_construct_properties,
                                                 construct_properties);
 
-        priv = PRIVATE (obj);
+        systz = SYSTEM_TIMEZONE (obj);
+        priv = systz->priv;
 
         priv->tz = system_timezone_find ();
 
@@ -202,7 +198,11 @@ static void
 system_timezone_finalize (GObject *obj)
 {
         int i;
-        SystemTimezonePrivate *priv = PRIVATE (obj);
+        SystemTimezone *systz;
+        SystemTimezonePrivate *priv;
+
+        systz = SYSTEM_TIMEZONE (obj);
+        priv = systz->priv;
 
         if (priv->tz) {
                 g_free (priv->tz);
@@ -229,9 +229,13 @@ system_timezone_monitor_changed (GFileMonitor *handle,
                                  GFileMonitorEvent event,
                                  gpointer user_data)
 {
-        SystemTimezonePrivate *priv = PRIVATE (user_data);
+        SystemTimezone *systz;
+        SystemTimezonePrivate *priv;
         char *new_tz;
 
+        systz = SYSTEM_TIMEZONE (user_data);
+        priv = systz->priv;
+
         if (event != G_FILE_MONITOR_EVENT_CHANGED &&
             event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT &&
             event != G_FILE_MONITOR_EVENT_DELETED &&
@@ -249,7 +253,6 @@ system_timezone_monitor_changed (GFileMonitor *handle,
                 g_free (new_tz);
 }
 
-
 /*
  * Code to deal with the system timezone on all distros.
  * There's no dependency on the SystemTimezone GObject here.
diff --git a/modules/clock/system-timezone.h b/modules/clock/system-timezone.h
index b001ec315..5361df4df 100644
--- a/modules/clock/system-timezone.h
+++ b/modules/clock/system-timezone.h
@@ -33,9 +33,13 @@ G_BEGIN_DECLS
 #define IS_SYSTEM_TIMEZONE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), SYSTEM_TIMEZONE_TYPE))
 #define SYSTEM_TIMEZONE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), SYSTEM_TIMEZONE_TYPE, 
SystemTimezoneClass))
 
+typedef struct _SystemTimezonePrivate SystemTimezonePrivate;
+
 typedef struct
 {
         GObject g_object;
+
+        SystemTimezonePrivate *priv;
 } SystemTimezone;
 
 typedef struct


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]