diff options
author | Thomas Wood <thomas.wood@intel.com> | 2010-06-28 11:41:37 +0100 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2010-06-28 11:41:37 +0100 |
commit | 8db6536da9fafc7ad61e0bec13d0239bd55235c1 (patch) | |
tree | b9138cc049582529fc80b3664e53d321c52a28e8 | |
parent | 402d7dce0391a5895f12750fe6c37fd5940f2d01 (diff) | |
download | gnome-control-center-8db6536da9fafc7ad61e0bec13d0239bd55235c1.tar.gz |
datetime: update the time labels when the location is changed
Update the time labels so that the time is changed accordingly with the
timezone.
-rw-r--r-- | panels/datetime/cc-datetime-panel.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c index 51b17f359..48e71d0e0 100644 --- a/panels/datetime/cc-datetime-panel.c +++ b/panels/datetime/cc-datetime-panel.c @@ -183,8 +183,12 @@ location_changed_cb (CcTimezoneMap *map, TzLocation *location, CcDateTimePanel *self) { - GtkWidget *label; + CcDateTimePanelPrivate *priv = self->priv; + GtkWidget *label, *widget; gchar *s, *p; + time_t t; + struct tm *ltime; + gchar slabel[32]; label = (GtkWidget *) gtk_builder_get_object (self->priv->builder, "label_current_location"); @@ -201,6 +205,25 @@ location_changed_cb (CcTimezoneMap *map, gtk_label_set_text (GTK_LABEL (label), s); g_free (s); + + + /* tz.c updates the local timezone, which means the spin buttons can be + * updated with the current time of the new location */ + + t = time (NULL); + ltime = localtime (&t); + + widget = (GtkWidget *) gtk_builder_get_object (priv->builder, "spin_hour"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), ltime->tm_hour); + widget = (GtkWidget *) gtk_builder_get_object (priv->builder, "spin_minute"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), ltime->tm_min); + widget = (GtkWidget *) gtk_builder_get_object (priv->builder, "spin_second"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), ltime->tm_sec); + + widget = (GtkWidget*) gtk_builder_get_object (priv->builder, + "label_current_time"); + strftime (slabel, 32, "%X", localtime (&t)); + gtk_label_set_text (GTK_LABEL (widget), slabel); } static void |