[gnome-control-center] shortcut-editor: hide editing dialog on Escape
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shortcut-editor: hide editing dialog on Escape
- Date: Thu, 8 Sep 2016 15:13:10 +0000 (UTC)
commit 4db1337664d73bb5e2e726795f7c5bd98abe9dd7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Aug 30 11:56:16 2016 -0300
shortcut-editor: hide editing dialog on Escape
When editing a standard shortcut, the current code only
cancels the editing on Escape, but doesn't hide the
dialog.
Fix that by properly handling the canceling of shortcut
editing and making sure we always hide the dialog on
cancel.
https://bugzilla.gnome.org/show_bug.cgi?id=769314
panels/keyboard/cc-keyboard-shortcut-editor.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-shortcut-editor.c b/panels/keyboard/cc-keyboard-shortcut-editor.c
index 33d37bd..bf974e6 100644
--- a/panels/keyboard/cc-keyboard-shortcut-editor.c
+++ b/panels/keyboard/cc-keyboard-shortcut-editor.c
@@ -154,6 +154,15 @@ clear_custom_entries (CcKeyboardShortcutEditor *self)
g_signal_handlers_unblock_by_func (self->name_entry, name_entry_changed_cb, self);
}
+static void
+cancel_editing (CcKeyboardShortcutEditor *self)
+{
+ cc_keyboard_shortcut_editor_set_item (self, NULL);
+ clear_custom_entries (self);
+
+ gtk_widget_hide (GTK_WIDGET (self));
+}
+
static gboolean
is_custom_shortcut (CcKeyboardShortcutEditor *self)
{
@@ -391,10 +400,7 @@ static void
cancel_button_clicked_cb (GtkWidget *button,
CcKeyboardShortcutEditor *self)
{
- cc_keyboard_shortcut_editor_set_item (self, NULL);
- clear_custom_entries (self);
-
- gtk_widget_hide (GTK_WIDGET (self));
+ cancel_editing (self);
}
static void
@@ -589,12 +595,13 @@ cc_keyboard_shortcut_editor_key_press_event (GtkWidget *widget,
{
CcKeyboardShortcutEditor *self;
GdkModifierType real_mask;
+ gboolean is_custom;
gboolean editing;
self = CC_KEYBOARD_SHORTCUT_EDITOR (widget);
- editing = !g_str_equal (gtk_stack_get_visible_child_name (GTK_STACK (self->stack)), "custom") ||
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->edit_button));
+ is_custom = is_custom_shortcut (self);
+ editing = !is_custom || gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->edit_button));
if (!editing)
return GTK_WIDGET_CLASS (cc_keyboard_shortcut_editor_parent_class)->key_press_event (widget, event);
@@ -609,6 +616,10 @@ cc_keyboard_shortcut_editor_key_press_event (GtkWidget *widget,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->edit_button), FALSE);
release_grab (self);
+ /* Hide the dialog when editing a standard shortcut */
+ if (!is_custom)
+ cancel_editing (self);
+
return GDK_EVENT_STOP;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]