diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-09-09 12:43:31 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-09-09 12:43:31 -0500 |
commit | cd6fa3bab97768ef37ac4d6e2499f1a45aae596f (patch) | |
tree | 25f766c32469671ab71ddf1c18a2fad22a49dfe5 /src/timezone-file.c | |
parent | b7f625ed8003197cd9d0a81240aea944860c8dc3 (diff) | |
download | ayatana-indicator-datetime-cd6fa3bab97768ef37ac4d6e2499f1a45aae596f.tar.gz ayatana-indicator-datetime-cd6fa3bab97768ef37ac4d6e2499f1a45aae596f.tar.bz2 ayatana-indicator-datetime-cd6fa3bab97768ef37ac4d6e2499f1a45aae596f.zip |
in the Datetime base class, make a set_timezone() function for subclasses s.t. they don't have to reinvent the wheel. As a result, also remove the 'timezone changed' signale emitter helper
Diffstat (limited to 'src/timezone-file.c')
-rw-r--r-- | src/timezone-file.c | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/src/timezone-file.c b/src/timezone-file.c index 2adf2ca..698ce3e 100644 --- a/src/timezone-file.c +++ b/src/timezone-file.c @@ -35,9 +35,7 @@ static GParamSpec * properties[PROP_LAST] = { 0 }; struct _IndicatorDatetimeTimezoneFilePriv { gchar * filename; - GFile * file; GFileMonitor * monitor; - gchar * timezone; }; typedef IndicatorDatetimeTimezoneFilePriv priv_t; @@ -56,26 +54,18 @@ reload (IndicatorDatetimeTimezoneFile * self) priv_t * p = self->priv; GError * err = NULL; - gchar * new_timezone = NULL; + gchar * timezone = NULL; - if (!g_file_get_contents (p->filename, &new_timezone, NULL, &err)) + if (!g_file_get_contents (p->filename, &timezone, NULL, &err)) { g_warning ("%s Unable to read timezone file '%s': %s", G_STRLOC, p->filename, err->message); g_error_free (err); } else { - g_strstrip (new_timezone); - - if (g_strcmp0 (p->timezone, new_timezone)) - { - g_free (p->timezone); - p->timezone = g_strdup (new_timezone); - g_debug ("%s new timezone set: '%s'", G_STRLOC, p->timezone); - indicator_datetime_timezone_notify_timezone (INDICATOR_DATETIME_TIMEZONE(self)); - } - - g_free (new_timezone); + g_strstrip (timezone); + indicator_datetime_timezone_set_timezone (INDICATOR_DATETIME_TIMEZONE(self), timezone); + g_free (timezone); } } @@ -83,17 +73,17 @@ static void set_filename (IndicatorDatetimeTimezoneFile * self, const char * filename) { GError * err; + GFile * file; priv_t * p = self->priv; g_clear_object (&p->monitor); - g_clear_object (&p->file); g_free (p->filename); p->filename = g_strdup (filename); - p->file = g_file_new_for_path (p->filename); - err = NULL; - p->monitor = g_file_monitor_file (p->file, G_FILE_MONITOR_NONE, NULL, &err); + file = g_file_new_for_path (p->filename); + p->monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &err); + g_object_unref (file); if (err != NULL) { g_warning ("%s Unable to monitor timezone file '%s': %s", G_STRLOC, TIMEZONE_FILE, err->message); @@ -109,16 +99,6 @@ set_filename (IndicatorDatetimeTimezoneFile * self, const char * filename) } /*** -**** IndicatorDatetimeTimezoneClass funcs -***/ - -static const char * -my_get_timezone (IndicatorDatetimeTimezone * self) -{ - return INDICATOR_DATETIME_TIMEZONE_FILE(self)->priv->timezone; -} - -/*** **** GObjectClass funcs ***/ @@ -167,7 +147,6 @@ my_dispose (GObject * o) priv_t * p = self->priv; g_clear_object (&p->monitor); - g_clear_object (&p->file); G_OBJECT_CLASS (indicator_datetime_timezone_file_parent_class)->dispose (o); } @@ -179,7 +158,6 @@ my_finalize (GObject * o) priv_t * p = self->priv; g_free (p->filename); - g_free (p->timezone); G_OBJECT_CLASS (indicator_datetime_timezone_file_parent_class)->finalize (o); } @@ -192,7 +170,6 @@ static void indicator_datetime_timezone_file_class_init (IndicatorDatetimeTimezoneFileClass * klass) { GObjectClass * object_class; - IndicatorDatetimeTimezoneClass * location_class; const GParamFlags flags = G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS; object_class = G_OBJECT_CLASS (klass); @@ -201,9 +178,6 @@ indicator_datetime_timezone_file_class_init (IndicatorDatetimeTimezoneFileClass object_class->set_property = my_set_property; object_class->get_property = my_get_property; - location_class = INDICATOR_DATETIME_TIMEZONE_CLASS (klass); - location_class->get_timezone = my_get_timezone; - g_type_class_add_private (klass, sizeof (IndicatorDatetimeTimezoneFilePriv)); /* install properties */ |