[gnome-control-center/wip/datetime-panel: 12/15] datetime: update the time labels when the location is changed
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/datetime-panel: 12/15] datetime: update the time labels when the location is changed
- Date: Mon, 28 Jun 2010 17:10:06 +0000 (UTC)
commit 8db6536da9fafc7ad61e0bec13d0239bd55235c1
Author: Thomas Wood <thomas wood intel com>
Date: Mon Jun 28 11:41:37 2010 +0100
datetime: update the time labels when the location is changed
Update the time labels so that the time is changed accordingly with the
timezone.
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 51b17f3..48e71d0 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]