[gtksourceview] completionlist: handle Escape keyval directly
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] completionlist: handle Escape keyval directly
- Date: Thu, 1 Sep 2022 03:18:30 +0000 (UTC)
commit 82bf5312033d7b50fbaf2d57e1f982b62e68a9b1
Author: Christian Hergert <chergert redhat com>
Date: Wed Aug 31 20:18:06 2022 -0700
completionlist: handle Escape keyval directly
Rather than use bindings for this (which won't allow us to pass along the
event further) we want to both hide the assistant and pass along the event
so that systems such as vim emulation/input methods can further process it.
gtksourceview/gtksourceassistant.c | 1 -
gtksourceview/gtksourcecompletionlist.c | 15 ++++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/gtksourceassistant.c b/gtksourceview/gtksourceassistant.c
index 19157a2f..200b4f93 100644
--- a/gtksourceview/gtksourceassistant.c
+++ b/gtksourceview/gtksourceassistant.c
@@ -253,7 +253,6 @@ _gtk_source_assistant_class_init (GtkSourceAssistantClass *klass)
klass->get_target_location = _gtk_source_assistant_real_get_target_location;
gtk_widget_class_install_action (widget_class, "assistant.hide", NULL,
_gtk_source_assistant_hide_action);
- gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "assistant.hide", NULL);
gtk_widget_class_set_css_name (widget_class, "GtkSourceAssistant");
}
diff --git a/gtksourceview/gtksourcecompletionlist.c b/gtksourceview/gtksourcecompletionlist.c
index 06962768..3ccb20f3 100644
--- a/gtksourceview/gtksourcecompletionlist.c
+++ b/gtksourceview/gtksourcecompletionlist.c
@@ -268,13 +268,22 @@ key_press_propagate_cb (GtkSourceCompletionList *self,
g_assert (GTK_SOURCE_IS_COMPLETION_LIST (self));
g_assert (GTK_IS_EVENT_CONTROLLER_KEY (key));
- if (gtk_event_controller_key_forward (key, GTK_WIDGET (self->listbox)))
+ parent = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_SOURCE_TYPE_VIEW);
+
+ /* Process Escape inline because we want to both hide our assistant
+ * but also allow the view to handle Escape too (which might pass it
+ * along to somehwere else like Vim emulation.
+ */
+
+ if (keyval == GDK_KEY_Escape)
+ {
+ gtk_widget_hide (GTK_WIDGET (self));
+ }
+ else if (gtk_event_controller_key_forward (key, GTK_WIDGET (self->listbox)))
{
return TRUE;
}
- parent = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_SOURCE_TYPE_VIEW);
-
if (GTK_SOURCE_IS_VIEW (parent))
{
return gtk_event_controller_key_forward (key, parent);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]