summaryrefslogtreecommitdiff
path: root/applets/clock/system-timezone.c
diff options
context:
space:
mode:
Diffstat (limited to 'applets/clock/system-timezone.c')
-rw-r--r--applets/clock/system-timezone.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c
index b1755aa9..a6f9c75d 100644
--- a/applets/clock/system-timezone.c
+++ b/applets/clock/system-timezone.c
@@ -213,8 +213,7 @@ system_timezone_constructor (GType type,
g_object_unref (file);
if (priv->monitors[i])
- g_signal_connect (G_OBJECT (priv->monitors[i]),
- "changed",
+ g_signal_connect (priv->monitors [i], "changed",
G_CALLBACK (system_timezone_monitor_changed),
obj);
}
@@ -234,20 +233,11 @@ system_timezone_finalize (GObject *obj)
systz = SYSTEM_TIMEZONE (obj);
priv = system_timezone_get_instance_private (systz);
- if (priv->tz) {
- g_free (priv->tz);
- priv->tz = NULL;
- }
-
- if (priv->env_tz) {
- g_free (priv->env_tz);
- priv->env_tz = NULL;
- }
+ g_clear_pointer (&priv->tz, g_free);
+ g_clear_pointer (&priv->env_tz, g_free);
for (i = 0; i < CHECK_NB; i++) {
- if (priv->monitors[i])
- g_object_unref (priv->monitors[i]);
- priv->monitors[i] = NULL;
+ g_clear_object (&priv->monitors[i]);
}
G_OBJECT_CLASS (system_timezone_parent_class)->finalize (obj);
@@ -265,9 +255,10 @@ system_timezone_monitor_changed (GFileMonitor *handle,
gpointer user_data)
{
SystemTimezonePrivate *priv;
- priv = system_timezone_get_instance_private (user_data);
char *new_tz;
+ priv = system_timezone_get_instance_private (user_data);
+
if (event != G_FILE_MONITOR_EVENT_CHANGED &&
event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT &&
event != G_FILE_MONITOR_EVENT_DELETED &&
@@ -280,16 +271,15 @@ system_timezone_monitor_changed (GFileMonitor *handle,
if (strcmp (priv->tz, new_tz) != 0) {
g_free (priv->tz);
- priv->tz = new_tz;
+ priv->tz = g_strdup (new_tz);
g_signal_emit (G_OBJECT (user_data),
system_timezone_signals[CHANGED],
0, priv->tz);
- } else
- g_free (new_tz);
+ }
+ g_free (new_tz);
}
-
/*
* Code to deal with the system timezone on all distros.
* There's no dependency on the SystemTimezone GObject here.
@@ -378,7 +368,6 @@ system_timezone_write_etc_timezone (const char *tz,
return retval;
}
-
/* Read a file that looks like a key-file (but there's no need for groups)
* and get the last value for a specific key */
static char *
@@ -413,16 +402,12 @@ system_timezone_read_key_file (const char *filename,
if (value[0] == '\"') {
if (value[len - 1] == '\"') {
- if (retval)
- g_free (retval);
-
+ g_free (retval);
retval = g_strndup (value + 1,
len - 2);
}
} else {
- if (retval)
- g_free (retval);
-
+ g_free (retval);
retval = g_strdup (line + strlen (key_eq));
}
@@ -720,7 +705,6 @@ recursive_compare (struct stat *localtime_stat,
return NULL;
}
-
static gboolean
files_are_identical_inode (struct stat *a_stat,
struct stat *b_stat,
@@ -731,7 +715,6 @@ files_are_identical_inode (struct stat *a_stat,
return (a_stat->st_ino == b_stat->st_ino);
}
-
/* Determine if /etc/localtime is a hard link to some file, by looking at
* the inodes */
static char *