aboutsummaryrefslogtreecommitdiff
path: root/src/idolocationmenuitem.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-12-03 22:14:51 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-12-03 22:14:51 +0000
commit0ab4079b28220f4051f8d0935a976e550514ad7f (patch)
tree7693892f4b07f9f222b76d91f641da41f0239d69 /src/idolocationmenuitem.c
parent3fded4665bfe9764faaeb657de791b0c553f6258 (diff)
downloadayatana-ido-0ab4079b28220f4051f8d0935a976e550514ad7f.tar.gz
ayatana-ido-0ab4079b28220f4051f8d0935a976e550514ad7f.tar.bz2
ayatana-ido-0ab4079b28220f4051f8d0935a976e550514ad7f.zip
Avoid deprecated g_type_class_add_private.
Diffstat (limited to 'src/idolocationmenuitem.c')
-rw-r--r--src/idolocationmenuitem.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/idolocationmenuitem.c b/src/idolocationmenuitem.c
index 335422a..eb6b38b 100644
--- a/src/idolocationmenuitem.c
+++ b/src/idolocationmenuitem.c
@@ -37,16 +37,13 @@ enum
static GParamSpec *properties[PROP_LAST];
-struct _IdoLocationMenuItemPrivate
-{
+typedef struct {
char * timezone;
guint timestamp_timer;
-};
+} IdoLocationMenuItemPrivate;
-typedef IdoLocationMenuItemPrivate priv_t;
-
-G_DEFINE_TYPE (IdoLocationMenuItem, ido_location_menu_item, IDO_TYPE_TIME_STAMP_MENU_ITEM);
+G_DEFINE_TYPE_WITH_PRIVATE (IdoLocationMenuItem, ido_location_menu_item, IDO_TYPE_TIME_STAMP_MENU_ITEM);
/***
**** Timestamp Label
@@ -58,7 +55,9 @@ update_timestamp (IdoLocationMenuItem * self)
GTimeZone * tz;
GDateTime * date_time;
- tz = g_time_zone_new (self->priv->timezone);
+ IdoLocationMenuItemPrivate * priv = ido_location_menu_item_get_instance_private(self);
+
+ tz = g_time_zone_new (priv->timezone);
if (tz == NULL)
tz = g_time_zone_new_local ();
date_time = g_date_time_new_now (tz);
@@ -73,7 +72,7 @@ update_timestamp (IdoLocationMenuItem * self)
static void
stop_timestamp_timer (IdoLocationMenuItem * self)
{
- priv_t * p = self->priv;
+ IdoLocationMenuItemPrivate * p = ido_location_menu_item_get_instance_private(self);
if (p->timestamp_timer != 0)
{
@@ -130,6 +129,7 @@ restart_timestamp_timer (IdoLocationMenuItem * self)
const char * fmt = ido_time_stamp_menu_item_get_format (IDO_TIME_STAMP_MENU_ITEM (self));
gboolean timestamp_shows_seconds;
int interval_sec;
+ IdoLocationMenuItemPrivate * priv = ido_location_menu_item_get_instance_private(self);
stop_timestamp_timer (self);
@@ -142,7 +142,7 @@ restart_timestamp_timer (IdoLocationMenuItem * self)
else
interval_sec = calculate_seconds_until_next_minute();
- self->priv->timestamp_timer = g_timeout_add_seconds (interval_sec,
+ priv->timestamp_timer = g_timeout_add_seconds (interval_sec,
on_timestamp_timer,
self);
}
@@ -158,7 +158,7 @@ my_get_property (GObject * o,
GParamSpec * pspec)
{
IdoLocationMenuItem * self = IDO_LOCATION_MENU_ITEM (o);
- priv_t * p = self->priv;
+ IdoLocationMenuItemPrivate * p = ido_location_menu_item_get_instance_private(self);
switch (property_id)
{
@@ -204,8 +204,9 @@ static void
my_finalize (GObject * object)
{
IdoLocationMenuItem * self = IDO_LOCATION_MENU_ITEM (object);
+ IdoLocationMenuItemPrivate * priv = ido_location_menu_item_get_instance_private(self);
- g_free (self->priv->timezone);
+ g_free (priv->timezone);
G_OBJECT_CLASS (ido_location_menu_item_parent_class)->finalize (object);
}
@@ -219,8 +220,6 @@ ido_location_menu_item_class_init (IdoLocationMenuItemClass *klass)
{
GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (IdoLocationMenuItemPrivate));
-
gobject_class->get_property = my_get_property;
gobject_class->set_property = my_set_property;
gobject_class->dispose = my_dispose;
@@ -239,10 +238,6 @@ ido_location_menu_item_class_init (IdoLocationMenuItemClass *klass)
static void
ido_location_menu_item_init (IdoLocationMenuItem *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- IDO_LOCATION_MENU_ITEM_TYPE,
- IdoLocationMenuItemPrivate);
-
/* Update the timer whenever the format string changes
because it determines whether we update once per second or per minute */
g_signal_connect (self, "notify::format",
@@ -271,10 +266,11 @@ void
ido_location_menu_item_set_timezone (IdoLocationMenuItem * self,
const char * timezone)
{
- priv_t * p;
+ IdoLocationMenuItemPrivate * p;
g_return_if_fail (IDO_IS_LOCATION_MENU_ITEM (self));
- p = self->priv;
+
+ p = ido_location_menu_item_get_instance_private(self);
g_free (p->timezone);
p->timezone = g_strdup (timezone);