From 784d8f89ded2472202594e41d62eb4596189182c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 8 Sep 2016 14:00:46 +0200 Subject: [PATCH] keyboard: Don't apply "Backspace" straight away Before, when pressing "Backspace" in the editing dialogue, the keybinding would be changed straight away, *behind* the dialogue, and the dialogue would still be expecting a new shortcut. Instead, we should make it behave like other shortcuts, which means special handling empty shortcuts as valid ones. https://bugzilla.gnome.org/show_bug.cgi?id=769314 --- panels/keyboard/cc-keyboard-shortcut-editor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/panels/keyboard/cc-keyboard-shortcut-editor.c b/panels/keyboard/cc-keyboard-shortcut-editor.c index 51b05c969..cb4580f6f 100644 --- a/panels/keyboard/cc-keyboard-shortcut-editor.c +++ b/panels/keyboard/cc-keyboard-shortcut-editor.c @@ -284,6 +284,8 @@ setup_custom_shortcut (CcKeyboardShortcutEditor *self) accel_valid = is_valid_binding (self->custom_keyval, self->custom_mask, self->custom_keycode) && gtk_accelerator_valid (self->custom_keyval, self->custom_mask) && !self->custom_is_modifier; + if (is_empty_binding (self->custom_keyval, self->custom_mask, self->custom_keycode)) + accel_valid = TRUE; valid = accel_valid; /* Additional checks for custom shortcuts */ @@ -663,13 +665,11 @@ cc_keyboard_shortcut_editor_key_press_event (GtkWidget *widget, if (!event->is_modifier && real_mask == 0 && event->keyval == GDK_KEY_BackSpace) { self->edited = TRUE; + self->custom_is_modifier = FALSE; self->custom_keycode = 0; self->custom_keyval = 0; self->custom_mask = 0; - if (self->item) - apply_custom_item_fields (self, self->item); - gtk_shortcut_label_set_accelerator (GTK_SHORTCUT_LABEL (self->custom_shortcut_accel_label), ""); gtk_shortcut_label_set_accelerator (GTK_SHORTCUT_LABEL (self->shortcut_accel_label), ""); @@ -678,6 +678,8 @@ cc_keyboard_shortcut_editor_key_press_event (GtkWidget *widget, self->edited = FALSE; + setup_custom_shortcut (self); + return GDK_EVENT_STOP; }