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
This commit is contained in:
Bastien Nocera 2016-09-08 14:00:46 +02:00
parent 69258a91a6
commit 784d8f89de

View file

@ -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;
}