aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-10-17 17:48:06 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-10-17 17:48:06 -0500
commit758a4880f645242f1c7753990dc46f880a7e9de8 (patch)
treebfa255867fc7069223109ae530ea1b60009dce7b
parentbcc04892148c7396e638f45e96fcba42d0034ec7 (diff)
downloadayatana-indicator-datetime-758a4880f645242f1c7753990dc46f880a7e9de8.tar.gz
ayatana-indicator-datetime-758a4880f645242f1c7753990dc46f880a7e9de8.tar.bz2
ayatana-indicator-datetime-758a4880f645242f1c7753990dc46f880a7e9de8.zip
cleanup: dead code removal, fix comments, smaller implementation of update_internal_localtime()
-rw-r--r--src/clock-live.c47
-rw-r--r--src/clock.c6
-rw-r--r--src/clock.h4
-rw-r--r--src/main.c6
-rw-r--r--src/service.c2
5 files changed, 24 insertions, 41 deletions
diff --git a/src/clock-live.c b/src/clock-live.c
index 6e694ed..564d990 100644
--- a/src/clock-live.c
+++ b/src/clock-live.c
@@ -35,7 +35,7 @@ struct _IndicatorDatetimeClockLivePriv
{
GSettings * settings;
- /* cached GTimeZone for use by indicator_datetime_service_get_localtime() */
+ /* cached GTimeZone for use by get_localtime() */
GTimeZone * internal_timezone;
IndicatorDatetimeTimezone * tz_file;
@@ -59,39 +59,10 @@ G_DEFINE_TYPE_WITH_CODE (
indicator_datetime_clock_interface_init));
/***
-**** Convenience func
-***/
-
-#if 0
-static void
-emit_changed (IndicatorDatetimeClockLive * self)
-{
- indicator_datetime_clock_emit_changed (INDICATOR_DATETIME_CLOCK (self));
-}
-#endif
-
-/***
**** Timezones
***/
static void
-update_internal_timezone (IndicatorDatetimeClockLive * self)
-{
- priv_t * p = self->priv;
- const char * id;
-
- /* find the id from tz_file or tz_geoclue if possible; NULL otherwise */
- id = NULL;
- if (p->tz_file != NULL )
- id = indicator_datetime_timezone_get_timezone (p->tz_file);
- if (!id && p->tz_geoclue)
- id = indicator_datetime_timezone_get_timezone (p->tz_geoclue);
-
- g_clear_pointer (&p->internal_timezone, g_time_zone_unref);
- p->internal_timezone = g_time_zone_new (id);
-}
-
-static void
on_current_timezone_changed (IndicatorDatetimeClockLive * self)
{
indicator_datetime_clock_emit_changed (INDICATOR_DATETIME_CLOCK (self));
@@ -159,7 +130,7 @@ on_detect_location_changed (IndicatorDatetimeClockLive * self)
***/
static gchar **
-my_get_timezones (IndicatorDatetimeClock * clock G_GNUC_UNUSED)
+my_get_timezones (IndicatorDatetimeClock * clock)
{
IndicatorDatetimeClockLive * self;
priv_t * p;
@@ -197,8 +168,18 @@ my_get_timezones (IndicatorDatetimeClock * clock G_GNUC_UNUSED)
return timezones;
}
+static void
+update_internal_timezone (IndicatorDatetimeClockLive * self)
+{
+ priv_t * p = self->priv;
+ gchar ** timezones = my_get_timezones (INDICATOR_DATETIME_CLOCK (self));
+ g_clear_pointer (&p->internal_timezone, g_time_zone_unref);
+ p->internal_timezone = g_time_zone_new (timezones ? timezones[0] : NULL);
+ g_strfreev (timezones);
+}
+
static GDateTime *
-my_get_current_time (IndicatorDatetimeClock * clock)
+my_get_localtime (IndicatorDatetimeClock * clock)
{
IndicatorDatetimeClockLive * self;
priv_t * p;
@@ -271,8 +252,8 @@ indicator_datetime_clock_live_class_init (IndicatorDatetimeClockLiveClass * klas
static void
indicator_datetime_clock_interface_init (IndicatorDatetimeClockInterface * iface)
{
+ iface->get_localtime = my_get_localtime;
iface->get_timezones = my_get_timezones;
- iface->get_current_time = my_get_current_time;
}
static void
diff --git a/src/clock.c b/src/clock.c
index 1abdd21..a5cefee 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -80,7 +80,7 @@ indicator_datetime_clock_get_timezones (IndicatorDatetimeClock * self)
* the current time.
*/
GDateTime *
-indicator_datetime_clock_get_current_time (IndicatorDatetimeClock * self)
+indicator_datetime_clock_get_localtime (IndicatorDatetimeClock * self)
{
GDateTime * now;
IndicatorDatetimeClockInterface * iface;
@@ -88,8 +88,8 @@ indicator_datetime_clock_get_current_time (IndicatorDatetimeClock * self)
g_return_val_if_fail (INDICATOR_IS_DATETIME_CLOCK(self), NULL);
iface = INDICATOR_DATETIME_CLOCK_GET_INTERFACE(self);
- if (iface->get_current_time != NULL)
- now = iface->get_current_time (self);
+ if (iface->get_localtime != NULL)
+ now = iface->get_localtime (self);
else
now = NULL;
diff --git a/src/clock.h b/src/clock.h
index 8932895..0c10dab 100644
--- a/src/clock.h
+++ b/src/clock.h
@@ -55,7 +55,7 @@ struct _IndicatorDatetimeClockInterface
/* virtual functions */
gchar** (*get_timezones) (IndicatorDatetimeClock * self);
- GDateTime* (*get_current_time) (IndicatorDatetimeClock * self);
+ GDateTime* (*get_localtime) (IndicatorDatetimeClock * self);
};
GType indicator_datetime_clock_get_type (void);
@@ -66,7 +66,7 @@ GType indicator_datetime_clock_get_type (void);
gchar ** indicator_datetime_clock_get_timezones (IndicatorDatetimeClock * clock);
-GDateTime * indicator_datetime_clock_get_current_time (IndicatorDatetimeClock * clock);
+GDateTime * indicator_datetime_clock_get_localtime (IndicatorDatetimeClock * clock);
void indicator_datetime_clock_emit_changed (IndicatorDatetimeClock * clock);
diff --git a/src/main.c b/src/main.c
index 9305794..dc08419 100644
--- a/src/main.c
+++ b/src/main.c
@@ -59,17 +59,19 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
if (!notify_init ("indicator-datetime-service"))
g_critical ("libnotify initialization failed");
- /* run */
+ /* create the service */
clock = indicator_datetime_clock_live_new ();
planner = indicator_datetime_planner_eds_new ();
service = indicator_datetime_service_new (clock, planner);
+
+ /* run */
loop = g_main_loop_new (NULL, FALSE);
g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST,
G_CALLBACK(on_name_lost), loop);
g_main_loop_run (loop);
+ g_main_loop_unref (loop);
/* cleanup */
- g_main_loop_unref (loop);
g_object_unref (service);
g_object_unref (planner);
g_object_unref (clock);
diff --git a/src/service.c b/src/service.c
index b777b8c..f2b0b34 100644
--- a/src/service.c
+++ b/src/service.c
@@ -166,7 +166,7 @@ indicator_clear_timer (guint * tag)
static inline GDateTime *
indicator_datetime_service_get_localtime (IndicatorDatetimeService * self)
{
- return indicator_datetime_clock_get_current_time (self->priv->clock);
+ return indicator_datetime_clock_get_localtime (self->priv->clock);
}
/***