[gnome-control-center/wip/gbsneto/keyboard-improvements: 15/22] shortcut-editor: cancel editing on Escape
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/keyboard-improvements: 15/22] shortcut-editor: cancel editing on Escape
- Date: Mon, 5 Sep 2016 14:54:25 +0000 (UTC)
commit 9903a4f138c7e03ed10993a8a55bc95ea4adc31e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Aug 30 11:56:16 2016 -0300
shortcut-editor: cancel editing 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 6190376..6f1d8b0 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)
{
@@ -386,10 +395,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
@@ -584,12 +590,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);
@@ -604,6 +611,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]