From 06fba30a17bf90da54fb5ef6bc9512cb72729895 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 17 Oct 2017 21:55:28 +0200
Subject: [PATCH 3/3] Revert "datetime: 12h time format is now always
available"
This reverts commit 85cd910af5e021f4ad1e34b4ae539a38aa712a61.
---
configure.ac | 2 +-
panels/datetime/cc-datetime-panel.c | 23 +++++++++++++++++++----
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index b16bc1931..9530d1e97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,7 @@ dnl ==============================================
dnl Check that we meet the dependencies
dnl ==============================================
-GLIB_REQUIRED_VERSION=2.53.0
+GLIB_REQUIRED_VERSION=2.44.0
GTK_REQUIRED_VERSION=3.22.0
PA_REQUIRED_VERSION=2.0
CANBERRA_REQUIRED_VERSION=0.13
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 5500b0503..a17b14d00 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -87,6 +87,7 @@ struct _CcDateTimePanelPrivate
GSettings *datetime_settings;
GSettings *filechooser_settings;
GDesktopClockFormat clock_format;
+ gboolean ampm_available;
GtkWidget *am_label;
GtkWidget *pm_label;
GtkWidget *am_pm_stack;
@@ -288,7 +289,7 @@ update_time (CcDateTimePanel *self)
g_signal_handlers_block_by_func (m_spinbutton, change_time, self);
g_signal_handlers_block_by_func (am_pm_button, am_pm_button_clicked, self);
- if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H)
+ if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H && priv->ampm_available)
use_ampm = TRUE;
else
use_ampm = FALSE;
@@ -540,7 +541,7 @@ update_timezone (CcDateTimePanel *self)
char *tz_desc;
gboolean use_ampm;
- if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H)
+ if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H && priv->ampm_available)
use_ampm = TRUE;
else
use_ampm = FALSE;
@@ -714,7 +715,7 @@ change_time (CcDateTimePanel *panel)
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("h_spinbutton")));
m = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("m_spinbutton")));
- if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H)
+ if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H && priv->ampm_available)
{
gboolean is_pm_time;
GtkWidget *visible_child;
@@ -1002,7 +1003,7 @@ format_hours_combobox (GtkSpinButton *spin,
int hour;
gboolean use_ampm;
- if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H)
+ if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H && priv->ampm_available)
use_ampm = TRUE;
else
use_ampm = FALSE;
@@ -1209,6 +1210,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
GtkWidget *widget;
GError *error;
GtkTreeModelSort *city_modelsort;
+ const char *ampm;
int ret;
const char *date_grid_name;
char *tmp;
@@ -1317,6 +1319,19 @@ cc_date_time_panel_init (CcDateTimePanel *self)
/* Clock settings */
priv->clock_settings = g_settings_new (CLOCK_SCHEMA);
+ ampm = nl_langinfo (AM_STR);
+ /* There are no AM/PM indicators for this locale, so
+ * offer the 24 hr clock as the only option */
+ if (ampm == NULL || ampm[0] == '\0')
+ {
+ gtk_widget_set_visible (W("timeformat-frame"), FALSE);
+ priv->ampm_available = FALSE;
+ }
+ else
+ {
+ priv->ampm_available = TRUE;
+ }
+
widget = W ("vbox_datetime");
gtk_container_add (GTK_CONTAINER (self), widget);
--
2.13.6