From 17a8595ddc47edb7d70d68d6114a181de1a0c3ac Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Tue, 17 Sep 2013 14:31:22 +0200 Subject: [PATCH] datetime: Sync AM/PM button's accessible name with the text displayed Instead of hardcoding the accessible name as "Switch between AM and PM.", set it to "AM" or "PM" depending on which label the stack switcher is currently showing. https://bugzilla.gnome.org/show_bug.cgi?id=708219 --- panels/datetime/cc-datetime-panel.c | 20 ++++++++++++++++++++ panels/datetime/datetime.ui | 5 ----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c index 50a840d15..3742890a8 100644 --- a/panels/datetime/cc-datetime-panel.c +++ b/panels/datetime/cc-datetime-panel.c @@ -240,6 +240,23 @@ clock_settings_changed_cb (GSettings *settings, g_signal_handlers_unblock_by_func (format_combo, change_clock_settings, panel); } +static void +am_pm_stack_visible_child_changed_cb (CcDateTimePanel *self) +{ + CcDateTimePanelPrivate *priv = self->priv; + AtkObject *am_pm_button_accessible; + GtkWidget *visible_label; + const gchar *visible_text; + + am_pm_button_accessible = gtk_widget_get_accessible (W ("am_pm_button")); + if (am_pm_button_accessible == NULL) + return; + + visible_label = gtk_stack_get_visible_child (GTK_STACK (W ("am_pm_stack"))); + visible_text = gtk_label_get_text (GTK_LABEL (visible_label)); + atk_object_set_name (am_pm_button_accessible, visible_text); +} + static gboolean am_pm_button_clicked (GtkWidget *button, CcDateTimePanel *self) @@ -1114,6 +1131,9 @@ setup_am_pm_button (CcDateTimePanel *self) gtk_container_add (GTK_CONTAINER (stack), priv->am_label); gtk_container_add (GTK_CONTAINER (stack), priv->pm_label); gtk_widget_show_all (stack); + g_signal_connect_swapped (stack, "notify::visible-child", + G_CALLBACK (am_pm_stack_visible_child_changed_cb), self); + am_pm_stack_visible_child_changed_cb (self); am_pm_button = W ("am_pm_button"); g_signal_connect (am_pm_button, "clicked", diff --git a/panels/datetime/datetime.ui b/panels/datetime/datetime.ui index c33be5125..7aa2a1b16 100644 --- a/panels/datetime/datetime.ui +++ b/panels/datetime/datetime.ui @@ -196,11 +196,6 @@ - - - Switch between AM and PM. - - True