[gnome-calendar] time-selector: fix 12-hour format
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] time-selector: fix 12-hour format
- Date: Thu, 28 Jul 2016 19:42:30 +0000 (UTC)
commit c16864ff97b37a196f5adfa35ca6f134cbd4e3a5
Author: Ernestas Kulik <ernestask src gnome org>
Date: Thu Jul 28 00:46:36 2016 +0300
time-selector: fix 12-hour format
Currently, the date selector allows hours in range [0; 11], which is not
the convention. This commit fixes the conversion logic.
https://bugzilla.gnome.org/show_bug.cgi?id=756377
src/gcal-time-selector.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/src/gcal-time-selector.c b/src/gcal-time-selector.c
index a5d432f..781bf9b 100644
--- a/src/gcal-time-selector.c
+++ b/src/gcal-time-selector.c
@@ -101,14 +101,19 @@ update_time (GcalTimeSelector *selector)
hour = (gint) gtk_adjustment_get_value (selector->hour_adjustment);
minute = (gint) gtk_adjustment_get_value (selector->minute_adjustment);
- if (!selector->format_24h && gtk_combo_box_get_active (GTK_COMBO_BOX (selector->period_combo)) == PM)
+ if (!selector->format_24h)
{
- g_signal_handlers_block_by_func (selector->period_combo, update_time, selector);
+ hour = hour % 12;
- gtk_combo_box_set_active (GTK_COMBO_BOX (selector->period_combo), hour > 12);
- hour += 12;
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (selector->period_combo)) == PM)
+ {
+ g_signal_handlers_block_by_func (selector->period_combo, update_time, selector);
- g_signal_handlers_unblock_by_func (selector->period_combo, update_time, selector);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (selector->period_combo), hour >= 12);
+ hour += 12;
+
+ g_signal_handlers_unblock_by_func (selector->period_combo, update_time, selector);
+ }
}
now = g_date_time_new_now_local ();
@@ -190,9 +195,15 @@ gcal_time_selector_set_time_format (GcalTimeSelector *selector,
gtk_widget_set_visible (selector->period_combo, !format_24h);
if (format_24h)
- gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (selector->hour_spin)), 23.0);
+ {
+ gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (selector->hour_spin)), 0.0);
+ gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (selector->hour_spin)),
23.0);
+ }
else
- gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (selector->hour_spin)), 11.0);
+ {
+ gtk_adjustment_set_lower (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (selector->hour_spin)), 1.0);
+ gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (selector->hour_spin)),
12.0);
+ }
}
static void
@@ -289,6 +300,7 @@ gcal_time_selector_set_time (GcalTimeSelector *selector,
gtk_combo_box_set_active (GTK_COMBO_BOX (selector->period_combo), hour >= 12);
hour = hour % 12;
+ hour = (hour == 0)? 12 : hour;
g_signal_handlers_unblock_by_func (selector->period_combo, update_time, selector);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]