From 60894665c424ff487caf294b9cd5f72c753a4a4f Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Wed, 11 Sep 2019 21:42:09 +0800 Subject: clock: avoid deprecated g_type_class_add_private --- applets/clock/calendar-window.c | 8 ++--- applets/clock/clock-face.c | 36 +++++++++----------- applets/clock/clock-location-tile.c | 45 ++++++++++++++----------- applets/clock/clock-location.c | 66 +++++++++++++++++-------------------- applets/clock/clock-map.c | 32 ++++++++---------- applets/clock/system-timezone.c | 28 +++++++++------- 6 files changed, 104 insertions(+), 111 deletions(-) (limited to 'applets') diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index e230088d..d47189d6 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -39,8 +39,6 @@ #include "clock-utils.h" #include "clock-typebuiltins.h" -#define CALENDAR_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_WINDOW, CalendarWindowPrivate)) - #define KEY_LOCATIONS_EXPANDED "expand-locations" enum { @@ -64,7 +62,7 @@ struct _CalendarWindowPrivate { GSettings *settings; }; -G_DEFINE_TYPE (CalendarWindow, calendar_window, GTK_TYPE_WINDOW) +G_DEFINE_TYPE_WITH_PRIVATE (CalendarWindow, calendar_window, GTK_TYPE_WINDOW) enum { PROP_0, @@ -423,8 +421,6 @@ calendar_window_class_init (CalendarWindowClass *klass) 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, @@ -475,7 +471,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/applets/clock/clock-face.c b/applets/clock/clock-face.c index 36603865..ef5afdc3 100644 --- a/applets/clock/clock-face.c +++ b/applets/clock/clock-face.c @@ -22,10 +22,6 @@ static GHashTable *pixbuf_cache = NULL; -#define CLOCK_FACE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), INTL_TYPE_CLOCK_FACE, ClockFacePrivate)) - -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); @@ -65,6 +61,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) { @@ -82,14 +80,12 @@ 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 clock_face_init (ClockFace *this) { - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this); + ClockFacePrivate *priv = clock_face_get_instance_private (this); priv->size = CLOCK_FACE_SMALL; priv->timeofday = CLOCK_FACE_INVALID; @@ -111,7 +107,7 @@ clock_face_draw (GtkWidget *this, cairo_t *cr) /* Hand lengths as a multiple of the clock radius */ double hour_length, min_length, sec_length; - priv = CLOCK_FACE_GET_PRIVATE (this); + priv = clock_face_get_instance_private (CLOCK_FACE(this)); if (GTK_WIDGET_CLASS (clock_face_parent_class)->draw) GTK_WIDGET_CLASS (clock_face_parent_class)->draw (this, cr); @@ -194,7 +190,7 @@ clock_face_get_preferred_width (GtkWidget *this, gint *minimal_width, gint *natural_width) { - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this); + ClockFacePrivate *priv = clock_face_get_instance_private (CLOCK_FACE(this)); if (priv->size_widget != NULL) { int child_minimal_height; @@ -227,7 +223,7 @@ clock_face_get_preferred_height (GtkWidget *this, gint *minimal_height, gint *natural_height) { - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this); + ClockFacePrivate *priv = clock_face_get_instance_private (CLOCK_FACE(this)); if (priv->size_widget != NULL) { int child_minimal_height; @@ -283,9 +279,9 @@ update_time_and_face (ClockFace *this, gboolean force_face_loading) { ClockFacePrivate *priv; - ClockFaceTimeOfDay timeofday; + ClockFaceTimeOfDay timeofday; - priv = CLOCK_FACE_GET_PRIVATE (this); + priv = clock_face_get_instance_private (this); /* update the time */ if (priv->location) { @@ -346,7 +342,7 @@ GtkWidget * clock_face_new (ClockFaceSize size) { GObject *obj = g_object_new (INTL_TYPE_CLOCK_FACE, NULL); - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj); + ClockFacePrivate *priv = clock_face_get_instance_private (CLOCK_FACE(obj)); priv->size = size; @@ -359,7 +355,7 @@ clock_face_new_with_location (ClockFaceSize size, GtkWidget *size_widget) { GObject *obj = g_object_new (INTL_TYPE_CLOCK_FACE, NULL); - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj); + ClockFacePrivate *priv = clock_face_get_instance_private (CLOCK_FACE(obj)); priv->size = size; priv->location = g_object_ref (loc); @@ -371,7 +367,7 @@ clock_face_new_with_location (ClockFaceSize size, static void clock_face_finalize (GObject *obj) { - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj); + ClockFacePrivate *priv = clock_face_get_instance_private (CLOCK_FACE(obj)); if (priv->location) { g_object_unref (priv->location); @@ -407,11 +403,11 @@ remove_pixbuf_from_cache (const char *key, static void clock_face_load_face (ClockFace *this, gint width, gint height) { - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this); - const gchar *size_string[2] = { "small", "large" }; - const gchar *daytime_string[4] = { "morning", "day", "evening", "night" }; - gchar *cache_name; - gchar *name; + ClockFacePrivate *priv = clock_face_get_instance_private (this); + const gchar *size_string[2] = { "small", "large" }; + const gchar *daytime_string[4] = { "morning", "day", "evening", "night" }; + gchar *cache_name; + gchar *name; if (!pixbuf_cache) pixbuf_cache = g_hash_table_new_full (g_str_hash, g_str_equal, diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c index 351e8c69..82db27c9 100644 --- a/applets/clock/clock-location-tile.c +++ b/applets/clock/clock-location-tile.c @@ -16,8 +16,6 @@ #include "clock-marshallers.h" #include "set-timezone.h" -G_DEFINE_TYPE (ClockLocationTile, clock_location_tile, GTK_TYPE_BIN) - enum { TILE_PRESSED, NEED_CLOCK_FORMAT, @@ -51,9 +49,9 @@ typedef struct { 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, WeatherInfo *info, gpointer data); @@ -71,7 +69,8 @@ clock_location_tile_new (ClockLocation *loc, ClockLocationTilePrivate *priv; this = g_object_new (CLOCK_LOCATION_TILE_TYPE, NULL); - priv = PRIVATE (this); + + priv = clock_location_tile_get_instance_private (this); priv->location = g_object_ref (loc); priv->size = size; @@ -96,8 +95,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, @@ -119,7 +116,7 @@ clock_location_tile_class_init (ClockLocationTileClass *this_class) static void clock_location_tile_init (ClockLocationTile *this) { - ClockLocationTilePrivate *priv = PRIVATE (this); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (this); priv->location = NULL; @@ -136,7 +133,11 @@ clock_location_tile_init (ClockLocationTile *this) static void clock_location_tile_finalize (GObject *g_obj) { - ClockLocationTilePrivate *priv = PRIVATE (g_obj); + ClockLocationTile *this; + ClockLocationTilePrivate *priv; + + this = CLOCK_LOCATION_TILE (g_obj); + priv = clock_location_tile_get_instance_private (this); if (priv->location) { g_signal_handler_disconnect (priv->location, priv->location_weather_updated_id); @@ -192,7 +193,7 @@ make_current_cb (gpointer data, GError *error) static void make_current (GtkWidget *widget, ClockLocationTile *tile) { - ClockLocationTilePrivate *priv = PRIVATE (tile); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (tile); clock_location_make_current (priv->location, (GFunc)make_current_cb, tile, NULL); @@ -203,7 +204,7 @@ enter_or_leave_tile (GtkWidget *widget, GdkEventCrossing *event, ClockLocationTile *tile) { - ClockLocationTilePrivate *priv = PRIVATE (tile); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (tile); if (event->mode != GDK_CROSSING_NORMAL) { return TRUE; @@ -253,7 +254,7 @@ enter_or_leave_tile (GtkWidget *widget, static void clock_location_tile_fill (ClockLocationTile *this) { - ClockLocationTilePrivate *priv = PRIVATE (this); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (this); GtkWidget *strut; GtkWidget *box; GtkWidget *tile; @@ -356,7 +357,7 @@ clock_location_tile_fill (ClockLocationTile *this) static gboolean clock_needs_face_refresh (ClockLocationTile *this) { - ClockLocationTilePrivate *priv = PRIVATE (this); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (this); struct tm now; clock_location_localtime (priv->location, &now); @@ -380,7 +381,7 @@ clock_needs_face_refresh (ClockLocationTile *this) static gboolean clock_needs_label_refresh (ClockLocationTile *this) { - ClockLocationTilePrivate *priv = PRIVATE (this); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (this); struct tm now; long offset; @@ -519,7 +520,7 @@ convert_time_to_str (time_t now, ClockFormat clock_format) void clock_location_tile_refresh (ClockLocationTile *this, gboolean force_refresh) { - ClockLocationTilePrivate *priv = PRIVATE (this); + ClockLocationTilePrivate *priv = clock_location_tile_get_instance_private (this); gchar *tmp, *tzname; struct tm now; long offset; @@ -661,11 +662,13 @@ weather_tooltip (GtkWidget *widget, GtkTooltip *tooltip, gpointer data) { - ClockLocationTile *tile = data; - ClockLocationTilePrivate *priv = PRIVATE (tile); + ClockLocationTile *tile; + ClockLocationTilePrivate *priv; WeatherInfo *info; int clock_format; + tile = CLOCK_LOCATION_TILE (data); + priv = clock_location_tile_get_instance_private (tile); info = clock_location_get_weather_info (priv->location); if (!info || !weather_info_is_valid (info)) @@ -681,8 +684,8 @@ weather_tooltip (GtkWidget *widget, static void update_weather_icon (ClockLocation *loc, WeatherInfo *info, gpointer data) { - ClockLocationTile *tile = data; - ClockLocationTilePrivate *priv = PRIVATE (tile); + ClockLocationTile *tile; + ClockLocationTilePrivate *priv; cairo_surface_t *surface = NULL; GtkIconTheme *theme = NULL; const gchar *icon_name; @@ -691,6 +694,8 @@ update_weather_icon (ClockLocation *loc, WeatherInfo *info, gpointer data) if (!info || !weather_info_is_valid (info)) return; + tile = CLOCK_LOCATION_TILE (data); + priv = clock_location_tile_get_instance_private (tile); theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (priv->weather_icon))); icon_name = weather_info_get_icon_name (info); icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (priv->weather_icon)); @@ -711,7 +716,7 @@ clock_location_tile_get_location (ClockLocationTile *this) g_return_val_if_fail (IS_CLOCK_LOCATION_TILE (this), NULL); - priv = PRIVATE (this); + priv = clock_location_tile_get_instance_private (this); return g_object_ref (priv->location); } diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c index b0b7d32e..22ef32be 100644 --- a/applets/clock/clock-location.c +++ b/applets/clock/clock-location.c @@ -22,8 +22,6 @@ #include "set-timezone.h" #include "system-timezone.h" -G_DEFINE_TYPE (ClockLocation, clock_location, G_TYPE_OBJECT) - typedef struct { gchar *name; gchar *city; @@ -46,6 +44,8 @@ typedef struct { SpeedUnit speed_unit; } ClockLocationPrivate; +G_DEFINE_TYPE_WITH_PRIVATE (ClockLocation, clock_location, G_TYPE_OBJECT) + #define WEATHER_TIMEOUT_BASE 30 #define WEATHER_TIMEOUT_MAX 1800 #define WEATHER_EMPTY_CODE "-" @@ -66,8 +66,6 @@ static void setup_weather_updates (ClockLocation *loc); static gchar *clock_location_get_valid_weather_code (const gchar *code); -#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CLOCK_LOCATION_TYPE, ClockLocationPrivate)) - ClockLocation * clock_location_find_and_ref (GList *locations, const gchar *name, @@ -81,7 +79,7 @@ clock_location_find_and_ref (GList *locations, ClockLocationPrivate *priv; for (l = locations; l != NULL; l = l->next) { - priv = PRIVATE (l->data); + priv = clock_location_get_instance_private (l->data); if (priv->latitude == latitude && priv->longitude == longitude && @@ -108,7 +106,7 @@ clock_location_new (const gchar *name, const gchar *city, ClockLocationPrivate *priv; this = g_object_new (CLOCK_LOCATION_TYPE, NULL); - priv = PRIVATE (this); + priv = clock_location_get_instance_private (this); priv->name = g_strdup (name); priv->city = g_strdup (city); @@ -159,8 +157,6 @@ clock_location_class_init (ClockLocationClass *this_class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (this_class, sizeof (ClockLocationPrivate)); } static void @@ -168,7 +164,7 @@ network_changed (GNetworkMonitor *monitor, gboolean available, ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); if (available) { priv->weather_retry_time = WEATHER_TIMEOUT_BASE; @@ -179,7 +175,7 @@ network_changed (GNetworkMonitor *monitor, static void clock_location_init (ClockLocation *this) { - ClockLocationPrivate *priv = PRIVATE (this); + ClockLocationPrivate *priv = clock_location_get_instance_private (this); GNetworkMonitor *monitor; priv->name = NULL; @@ -205,7 +201,7 @@ clock_location_init (ClockLocation *this) static void clock_location_finalize (GObject *g_obj) { - ClockLocationPrivate *priv = PRIVATE (g_obj); + ClockLocationPrivate *priv = clock_location_get_instance_private (CLOCK_LOCATION(g_obj)); GNetworkMonitor *monitor; monitor = g_network_monitor_get_default (); @@ -259,7 +255,7 @@ clock_location_finalize (GObject *g_obj) const gchar * clock_location_get_display_name (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); if (priv->name && priv->name[0]) return priv->name; @@ -270,7 +266,7 @@ clock_location_get_display_name (ClockLocation *loc) const gchar * clock_location_get_name (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); return priv->name; } @@ -278,7 +274,7 @@ clock_location_get_name (ClockLocation *loc) void clock_location_set_name (ClockLocation *loc, const gchar *name) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); if (priv->name) { g_free (priv->name); @@ -291,7 +287,7 @@ clock_location_set_name (ClockLocation *loc, const gchar *name) const gchar * clock_location_get_city (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); return priv->city; } @@ -299,7 +295,7 @@ clock_location_get_city (ClockLocation *loc) void clock_location_set_city (ClockLocation *loc, const gchar *city) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); if (priv->city) { g_free (priv->city); @@ -312,7 +308,7 @@ clock_location_set_city (ClockLocation *loc, const gchar *city) gchar * clock_location_get_timezone (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); return priv->timezone; } @@ -320,7 +316,7 @@ clock_location_get_timezone (ClockLocation *loc) void clock_location_set_timezone (ClockLocation *loc, const gchar *timezone) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); if (priv->timezone) { g_free (priv->timezone); @@ -333,7 +329,7 @@ clock_location_set_timezone (ClockLocation *loc, const gchar *timezone) gchar * clock_location_get_tzname (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); return priv->tzname; } @@ -342,7 +338,7 @@ void clock_location_get_coords (ClockLocation *loc, gfloat *latitude, gfloat *longitude) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); *latitude = priv->latitude; *longitude = priv->longitude; @@ -352,7 +348,7 @@ void clock_location_set_coords (ClockLocation *loc, gfloat latitude, gfloat longitude) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); priv->latitude = latitude; priv->longitude = longitude; @@ -361,7 +357,7 @@ clock_location_set_coords (ClockLocation *loc, gfloat latitude, static void clock_location_set_tzname (ClockLocation *this, const char *tzname) { - ClockLocationPrivate *priv = PRIVATE (this); + ClockLocationPrivate *priv = clock_location_get_instance_private (CLOCK_LOCATION(this)); if (priv->tzname) { if (strcmp (priv->tzname, tzname) == 0) { @@ -382,7 +378,7 @@ clock_location_set_tzname (ClockLocation *this, const char *tzname) static void clock_location_set_tz (ClockLocation *this) { - ClockLocationPrivate *priv = PRIVATE (this); + ClockLocationPrivate *priv = clock_location_get_instance_private (this); time_t now_t; struct tm now; @@ -407,7 +403,7 @@ clock_location_set_tz (ClockLocation *this) static void clock_location_unset_tz (ClockLocation *this) { - ClockLocationPrivate *priv = PRIVATE (this); + ClockLocationPrivate *priv = clock_location_get_instance_private (this); const char *env_timezone; if (priv->timezone == NULL) { @@ -440,7 +436,7 @@ clock_location_localtime (ClockLocation *loc, struct tm *tm) gboolean clock_location_is_current_timezone (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); const char *zone; zone = system_timezone_get (priv->systz); @@ -479,7 +475,7 @@ clock_location_is_current (ClockLocation *loc) glong clock_location_get_offset (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); glong sys_timezone, local_timezone; glong offset; time_t t; @@ -557,7 +553,7 @@ clock_location_make_current (ClockLocation *loc, gpointer data, GDestroyNotify destroy) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); gchar *filename; MakeCurrentData *mcdata; @@ -610,7 +606,7 @@ clock_location_get_valid_weather_code (const gchar *code) const gchar * clock_location_get_weather_code (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); return priv->weather_code; } @@ -618,7 +614,7 @@ clock_location_get_weather_code (ClockLocation *loc) void clock_location_set_weather_code (ClockLocation *loc, const gchar *code) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); g_free (priv->weather_code); priv->weather_code = clock_location_get_valid_weather_code (code); @@ -629,7 +625,7 @@ clock_location_set_weather_code (ClockLocation *loc, const gchar *code) WeatherInfo * clock_location_get_weather_info (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); return priv->weather_info; } @@ -637,7 +633,7 @@ clock_location_get_weather_info (ClockLocation *loc) static void set_weather_update_timeout (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); guint timeout; if (!weather_info_network_error (priv->weather_info)) { @@ -667,7 +663,7 @@ static void weather_info_updated (WeatherInfo *info, gpointer data) { ClockLocation *loc = data; - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); set_weather_update_timeout (loc); g_signal_emit (loc, location_signals[WEATHER_UPDATED], @@ -678,7 +674,7 @@ static gboolean update_weather_info (gpointer data) { ClockLocation *loc = (ClockLocation *) data; - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); WeatherPrefs prefs = { FORECAST_STATE, FALSE, @@ -725,7 +721,7 @@ rad2dms (gfloat lat, gfloat lon) static void setup_weather_updates (ClockLocation *loc) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); WeatherLocation *wl; WeatherPrefs prefs = { FORECAST_STATE, @@ -773,7 +769,7 @@ void clock_location_set_weather_prefs (ClockLocation *loc, WeatherPrefs *prefs) { - ClockLocationPrivate *priv = PRIVATE (loc); + ClockLocationPrivate *priv = clock_location_get_instance_private (loc); priv->temperature_unit = prefs->temperature_unit; priv->speed_unit = prefs->speed_unit; diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c index 5b823ea4..0c371ca1 100644 --- a/applets/clock/clock-map.c +++ b/applets/clock/clock-map.c @@ -12,8 +12,6 @@ #include "clock-sunpos.h" #include "clock-marshallers.h" -G_DEFINE_TYPE (ClockMap, clock_map, GTK_TYPE_WIDGET) - enum { NEED_LOCATIONS, LAST_SIGNAL @@ -54,6 +52,8 @@ typedef struct { 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_size_allocate (GtkWidget *this, GtkAllocation *allocation); @@ -69,8 +69,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)) - ClockMap * clock_map_new (void) { @@ -96,8 +94,6 @@ clock_map_class_init (ClockMapClass *this_class) widget_class->get_preferred_width = clock_map_get_preferred_width; widget_class->get_preferred_height = clock_map_get_preferred_height; - g_type_class_add_private (this_class, sizeof (ClockMapPrivate)); - /** * ClockMap::need-locations * @@ -122,7 +118,7 @@ static void clock_map_init (ClockMap *this) { int i; - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (this); gtk_widget_set_has_window (GTK_WIDGET (this), FALSE); @@ -146,7 +142,7 @@ clock_map_init (ClockMap *this) static void clock_map_finalize (GObject *g_obj) { - ClockMapPrivate *priv = PRIVATE (g_obj); + ClockMapPrivate *priv = clock_map_get_instance_private (CLOCK_MAP(g_obj)); int i; if (priv->highlight_timeout_id) { @@ -187,7 +183,7 @@ clock_map_finalize (GObject *g_obj) void clock_map_refresh (ClockMap *this) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (this); GtkWidget *widget = GTK_WIDGET (this); GtkAllocation allocation; @@ -225,7 +221,7 @@ clock_map_refresh (ClockMap *this) static gboolean clock_map_draw (GtkWidget *this, cairo_t *cr) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (CLOCK_MAP(this)); int width, height; GtkStyleContext *context; GdkRGBA color; @@ -274,7 +270,7 @@ clock_map_get_preferred_height (GtkWidget *this, static void clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (CLOCK_MAP(this)); if (GTK_WIDGET_CLASS (clock_map_parent_class)->size_allocate) GTK_WIDGET_CLASS (clock_map_parent_class)->size_allocate (this, allocation); @@ -287,7 +283,7 @@ clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation) static void clock_map_mark (ClockMap *this, gfloat latitude, gfloat longitude, gint mark) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (this); GdkPixbuf *marker = priv->location_marker_pixbuf[mark]; GdkPixbuf *partial = NULL; @@ -432,7 +428,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 = clock_map_get_instance_private (this); GList *locs; ClockLocation *loc; @@ -559,7 +555,7 @@ clock_map_render_shadow_pixbuf (GdkPixbuf *pixbuf) static void clock_map_render_shadow (ClockMap *this) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (this); if (priv->shadow_pixbuf) { g_object_unref (priv->shadow_pixbuf); @@ -587,7 +583,7 @@ clock_map_render_shadow (ClockMap *this) static void clock_map_display (ClockMap *this) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (this); if (priv->width > 0 || priv->height > 0) clock_map_render_shadow (this); @@ -629,7 +625,7 @@ highlight_destroy (gpointer user_data) BlinkData *data = user_data; ClockMapPrivate *priv; - priv = PRIVATE (data->map); + priv = clock_map_get_instance_private (data->map); priv->highlight_timeout_id = 0; g_object_unref (data->location); @@ -642,7 +638,7 @@ clock_map_blink_location (ClockMap *this, ClockLocation *loc) BlinkData *data; ClockMapPrivate *priv; - priv = PRIVATE (this); + priv = clock_map_get_instance_private (this); g_return_if_fail (IS_CLOCK_MAP (this)); g_return_if_fail (IS_CLOCK_LOCATION (loc)); @@ -666,7 +662,7 @@ clock_map_blink_location (ClockMap *this, ClockLocation *loc) static gboolean clock_map_needs_refresh (ClockMap *this) { - ClockMapPrivate *priv = PRIVATE (this); + ClockMapPrivate *priv = clock_map_get_instance_private (this); time_t now_t; time (&now_t); diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c index 6aa1c5ae..bed4aaaf 100644 --- a/applets/clock/system-timezone.c +++ b/applets/clock/system-timezone.c @@ -76,8 +76,6 @@ static char *files_to_check[CHECK_NB] = { static GObject *systz_singleton = NULL; -G_DEFINE_TYPE (SystemTimezone, system_timezone, G_TYPE_OBJECT) - typedef struct { char *tz; char *env_tz; @@ -89,6 +87,8 @@ enum { LAST_SIGNAL }; +G_DEFINE_TYPE_WITH_PRIVATE (SystemTimezone, system_timezone, G_TYPE_OBJECT) + static guint system_timezone_signals[LAST_SIGNAL] = { 0 }; static GObject *system_timezone_constructor (GType type, @@ -103,8 +103,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) { @@ -118,7 +116,7 @@ system_timezone_get (SystemTimezone *systz) g_return_val_if_fail (IS_SYSTEM_TIMEZONE (systz), NULL); - priv = PRIVATE (systz); + priv = system_timezone_get_instance_private (systz); return priv->tz; } @@ -129,7 +127,7 @@ system_timezone_get_env (SystemTimezone *systz) g_return_val_if_fail (IS_SYSTEM_TIMEZONE (systz), NULL); - priv = PRIVATE (systz); + priv = system_timezone_get_instance_private (systz); return priv->env_tz; } @@ -149,15 +147,14 @@ system_timezone_class_init (SystemTimezoneClass *class) NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - - g_type_class_add_private (class, sizeof (SystemTimezonePrivate)); } static void system_timezone_init (SystemTimezone *systz) { int i; - SystemTimezonePrivate *priv = PRIVATE (systz); + SystemTimezonePrivate *priv; + priv = system_timezone_get_instance_private (systz); priv->tz = NULL; priv->env_tz = NULL; @@ -171,6 +168,7 @@ system_timezone_constructor (GType type, GObjectConstructParam *construct_properties) { GObject *obj; + SystemTimezone *systz; SystemTimezonePrivate *priv; int i; @@ -183,7 +181,8 @@ system_timezone_constructor (GType type, n_construct_properties, construct_properties); - priv = PRIVATE (obj); + systz = SYSTEM_TIMEZONE (obj); + priv = system_timezone_get_instance_private (systz); priv->tz = system_timezone_find (); @@ -229,7 +228,11 @@ static void system_timezone_finalize (GObject *obj) { int i; - SystemTimezonePrivate *priv = PRIVATE (obj); + SystemTimezone *systz; + SystemTimezonePrivate *priv; + + systz = SYSTEM_TIMEZONE (obj); + priv = system_timezone_get_instance_private (systz); if (priv->tz) { g_free (priv->tz); @@ -261,7 +264,8 @@ system_timezone_monitor_changed (GFileMonitor *handle, GFileMonitorEvent event, gpointer user_data) { - SystemTimezonePrivate *priv = PRIVATE (user_data); + SystemTimezonePrivate *priv; + priv = system_timezone_get_instance_private (user_data); char *new_tz; if (event != G_FILE_MONITOR_EVENT_CHANGED && -- cgit v1.2.1