Created
December 17, 2013 01:51
-
-
Save sgnn7/cda827af22f3fc778b4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: gnome-initial-setup-0.12/gnome-initial-setup/pages/location/gis-location-page.c | |
=================================================================== | |
--- gnome-initial-setup-0.12.orig/gnome-initial-setup/pages/location/gis-location-page.c 2013-12-16 19:42:29.000000000 -0600 | |
+++ gnome-initial-setup-0.12/gnome-initial-setup/pages/location/gis-location-page.c 2013-12-16 19:45:29.354775391 -0600 | |
@@ -294,7 +294,7 @@ | |
} | |
static void | |
-queue_set_datetime (GisLocationPage *page) | |
+queue_set_time (GisLocationPage *page) | |
{ | |
GisLocationPagePrivate *priv = page->priv; | |
gint64 unixtime; | |
@@ -312,6 +312,122 @@ | |
} | |
static void | |
+set_date_cb (GObject *source, GAsyncResult *res, gpointer user_data) | |
+{ | |
+ GisLocationPage *page = user_data; | |
+ GError *error = NULL; | |
+ | |
+ if(!timedate1_call_set_time_finish (page->priv->dtm, res, &error)) | |
+ { | |
+ g_warning ("Could not set system time: %s", error->message); | |
+ g_error_free (error); | |
+ } | |
+} | |
+ | |
+static void | |
+queue_set_date (GisLocationPage *page) | |
+{ | |
+ GisLocationPagePrivate *priv = page->priv; | |
+ gint64 unixtime; | |
+ | |
+ /* timedated expects number of microseconds since 1 Jan 1970 UTC */ | |
+ unixtime = g_date_time_to_unix (priv->date); | |
+ | |
+ timedate1_call_set_time (priv->dtm, | |
+ unixtime * G_TIME_SPAN_SECOND, | |
+ FALSE, | |
+ TRUE, | |
+ priv->cancellable, | |
+ set_date_cb, | |
+ page); | |
+} | |
+ | |
+static void | |
+change_date (GisLocationPage *page) | |
+{ | |
+ GDateTime *old_date = page->priv->date; | |
+ guint month, year, day; | |
+ | |
+ month = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (WID ("month-combobox"))); | |
+ year = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (WID ("year-spinbutton"))); | |
+ day = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (WID ("day-spinbutton"))); | |
+ | |
+ page->priv->date = g_date_time_new_local (year, month, day, | |
+ g_date_time_get_hour (old_date), | |
+ g_date_time_get_minute (old_date), | |
+ g_date_time_get_second (old_date)); | |
+ g_date_time_unref (old_date); | |
+ queue_set_date (page); | |
+} | |
+ | |
+static void | |
+month_year_changed (GtkWidget *widget, GisLocationPage *page) | |
+{ | |
+ GtkAdjustment *adj; | |
+ GtkSpinButton *day_spin; | |
+ guint month; | |
+ guint num_days; | |
+ guint year; | |
+ | |
+ month = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (WID ("month-combobox"))); | |
+ year = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (WID ("year-spinbutton"))); | |
+ | |
+ num_days = g_date_get_days_in_month (month, year); | |
+ | |
+ day_spin = GTK_SPIN_BUTTON (WID ("day-spinbutton")); | |
+ adj = GTK_ADJUSTMENT (gtk_spin_button_get_adjustment (day_spin)); | |
+ gtk_adjustment_set_upper (adj, num_days + 1); | |
+ | |
+ if (gtk_spin_button_get_value_as_int (day_spin) > num_days) | |
+ gtk_spin_button_set_value (day_spin, num_days); | |
+ | |
+ change_date (page); | |
+} | |
+ | |
+static void | |
+day_changed (GtkWidget *widget, GisLocationPage *page) | |
+{ | |
+ change_date (page); | |
+} | |
+ | |
+static void | |
+update_date (GisLocationPage *page) | |
+{ | |
+ GtkWidget *day_widget = WID ("day-spinbutton"); | |
+ GtkWidget *month_widget = WID ("month-combobox"); | |
+ GtkWidget *year_widget = WID ("year-spinbutton"); | |
+ | |
+ /* Disable the system time updates while the UI is redrawn */ | |
+ g_signal_handlers_block_by_func( GTK_SPIN_BUTTON (day_widget), | |
+ G_CALLBACK (day_changed), page); | |
+ g_signal_handlers_block_by_func( GTK_COMBO_BOX (month_widget), | |
+ G_CALLBACK (month_year_changed), page); | |
+ g_signal_handlers_block_by_func( GTK_SPIN_BUTTON (year_widget), | |
+ G_CALLBACK (month_year_changed), page); | |
+ | |
+ /* Update the UI */ | |
+ GisLocationPagePrivate *priv = page->priv; | |
+ | |
+ gint day_of_month = g_date_time_get_day_of_month (priv->date); | |
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (day_widget), day_of_month); | |
+ | |
+ gint month = g_date_time_get_month (priv->date); | |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (month_widget), month - 1); | |
+ | |
+ gint year = g_date_time_get_year (priv->date); | |
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (year_widget), year); | |
+ | |
+ | |
+ /* Re-enable the system time updates from the UI */ | |
+ g_signal_handlers_unblock_by_func( GTK_SPIN_BUTTON (day_widget), | |
+ G_CALLBACK (day_changed), page); | |
+ g_signal_handlers_unblock_by_func( GTK_COMBO_BOX (month_widget), | |
+ G_CALLBACK (month_year_changed), page); | |
+ g_signal_handlers_unblock_by_func( GTK_SPIN_BUTTON (year_widget), | |
+ G_CALLBACK (month_year_changed), page); | |
+} | |
+ | |
+static void | |
change_time (GtkButton *button, GisLocationPage *page) | |
{ | |
GDateTime *old_date; | |
@@ -348,7 +464,7 @@ | |
g_date_time_unref (old_date); | |
update_time (page); | |
- queue_set_datetime (page); | |
+ queue_set_time (page); | |
} | |
static void | |
@@ -388,59 +504,12 @@ | |
} | |
static void | |
-change_date (GisLocationPage *page) | |
-{ | |
- GDateTime *old_date = page->priv->date; | |
- guint month, year, day; | |
- | |
- month = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (WID ("month-combobox"))); | |
- year = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (WID ("year-spinbutton"))); | |
- day = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (WID ("day-spinbutton"))); | |
- | |
- page->priv->date = g_date_time_new_local (year, month, day, | |
- g_date_time_get_hour (old_date), | |
- g_date_time_get_minute (old_date), | |
- g_date_time_get_second (old_date)); | |
- g_date_time_unref (old_date); | |
- queue_set_datetime (page); | |
-} | |
- | |
-static void | |
-month_year_changed (GtkWidget *widget, GisLocationPage *page) | |
-{ | |
- GtkAdjustment *adj; | |
- GtkSpinButton *day_spin; | |
- guint month; | |
- guint num_days; | |
- guint year; | |
- | |
- month = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (WID ("month-combobox"))); | |
- year = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (WID ("year-spinbutton"))); | |
- | |
- num_days = g_date_get_days_in_month (month, year); | |
- | |
- day_spin = GTK_SPIN_BUTTON (WID ("day-spinbutton")); | |
- adj = GTK_ADJUSTMENT (gtk_spin_button_get_adjustment (day_spin)); | |
- gtk_adjustment_set_upper (adj, num_days + 1); | |
- | |
- if (gtk_spin_button_get_value_as_int (day_spin) > num_days) | |
- gtk_spin_button_set_value (day_spin, num_days); | |
- | |
- change_date (page); | |
-} | |
- | |
-static void | |
-day_changed (GtkWidget *widget, GisLocationPage *page) | |
-{ | |
- change_date (page); | |
-} | |
- | |
-static void | |
clock_changed (GnomeWallClock *clock, GParamSpec *pspec, GisLocationPage *page) | |
{ | |
g_date_time_unref (page->priv->date); | |
page->priv->date = g_date_time_new_now_local (); | |
update_time (page); | |
+ update_date (page); | |
} | |
#define WANT_GEOCLUE 0 | |
@@ -658,6 +727,7 @@ | |
G_CALLBACK (clock_changed), page); | |
update_time (page); | |
+ update_date (page); | |
gis_page_set_complete (GIS_PAGE (page), TRUE); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment