From 778395f61b3af6c8aed8b241e0bddce4e9ed459c Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 31 Aug 2016 21:14:34 -0300 Subject: [PATCH] shortcut-editor: show custom page while waiting for input While waiting for keyboard input, as per the new proposed mockup, the shortcut editor dialog should show a custom page with an icon that indicates the required action. The current code, however, does not expose this new customized page. Fix that by adding this new page and controlling the time when it shows and hides. https://bugzilla.gnome.org/show_bug.cgi?id=769314 --- panels/keyboard/cc-keyboard-shortcut-editor.c | 11 ++++++- panels/keyboard/shortcut-editor.ui | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/panels/keyboard/cc-keyboard-shortcut-editor.c b/panels/keyboard/cc-keyboard-shortcut-editor.c index 550662a14..eac83b55e 100644 --- a/panels/keyboard/cc-keyboard-shortcut-editor.c +++ b/panels/keyboard/cc-keyboard-shortcut-editor.c @@ -48,6 +48,7 @@ struct _CcKeyboardShortcutEditor GtkWidget *set_button; GtkWidget *shortcut_accel_label; GtkWidget *shortcut_conflict_label; + GtkWidget *standard_shortcut_stack; GtkWidget *stack; GtkWidget *top_info_label; @@ -305,6 +306,10 @@ setup_custom_shortcut (CcKeyboardShortcutEditor *self) if (!accel_valid) return; + /* Valid shortcut, show it in the standard page */ + if (!is_custom) + gtk_stack_set_visible_child_name (GTK_STACK (self->standard_shortcut_stack), "main"); + shortcut_label = get_current_shortcut_label (self); collision_item = cc_keyboard_manager_get_collision (self->manager, @@ -512,7 +517,7 @@ setup_keyboard_item (CcKeyboardShortcutEditor *self, gtk_widget_hide (self->replace_button); /* Setup the top label */ - text = g_strdup_printf (_("Enter new shortcut to change %s, or press Esc to cancel."), item->description); + text = g_strdup_printf (_("Enter new shortcut to change %s."), item->description); gtk_label_set_markup (GTK_LABEL (self->top_info_label), text); @@ -552,6 +557,9 @@ setup_keyboard_item (CcKeyboardShortcutEditor *self, /* Show the apropriate view */ gtk_stack_set_visible_child_name (GTK_STACK (self->stack), is_custom ? "custom" : "edit"); + + if (!is_custom) + gtk_stack_set_visible_child_name (GTK_STACK (self->standard_shortcut_stack), "change-shortcut"); } static void @@ -764,6 +772,7 @@ cc_keyboard_shortcut_editor_class_init (CcKeyboardShortcutEditorClass *klass) gtk_widget_class_bind_template_child (widget_class, CcKeyboardShortcutEditor, set_button); gtk_widget_class_bind_template_child (widget_class, CcKeyboardShortcutEditor, shortcut_accel_label); gtk_widget_class_bind_template_child (widget_class, CcKeyboardShortcutEditor, shortcut_conflict_label); + gtk_widget_class_bind_template_child (widget_class, CcKeyboardShortcutEditor, standard_shortcut_stack); gtk_widget_class_bind_template_child (widget_class, CcKeyboardShortcutEditor, stack); gtk_widget_class_bind_template_child (widget_class, CcKeyboardShortcutEditor, top_info_label); diff --git a/panels/keyboard/shortcut-editor.ui b/panels/keyboard/shortcut-editor.ui index b6ba41d60..b8c0f1dd8 100644 --- a/panels/keyboard/shortcut-editor.ui +++ b/panels/keyboard/shortcut-editor.ui @@ -43,6 +43,37 @@ False True crossfade + + + True + False + vertical + 18 + True + center + center + + + True + False + /org/gnome/control-center/keyboard/enter-keyboard-shortcut.svg + + + + + True + False + Press Esc to cancel. + + + + + + change-shortcut + + True