[gimp] app: be smarter about handling the Space key in GimpPopup
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: be smarter about handling the Space key in GimpPopup
- Date: Tue, 12 Jul 2016 18:37:35 +0000 (UTC)
commit bb66166e229db3dd265093a01ddebe415caf5855
Author: Michael Natterer <mitch gimp org>
Date: Tue Jul 12 20:35:41 2016 +0200
app: be smarter about handling the Space key in GimpPopup
Don't remove the GDK_KEY_space in GimpSearchPopup because that's
impossible and removes it from the entire GimpPopup class. Instead,
don't handle the "space -> confirm" binding manually if the focus
widget is a text widget.
app/widgets/gimppopup.c | 42 ++++++++++++++++++++++++++++++----------
app/widgets/gimpsearchpopup.c | 8 -------
2 files changed, 31 insertions(+), 19 deletions(-)
---
diff --git a/app/widgets/gimppopup.c b/app/widgets/gimppopup.c
index 08417f8..a0b3e48 100644
--- a/app/widgets/gimppopup.c
+++ b/app/widgets/gimppopup.c
@@ -222,19 +222,39 @@ static gboolean
gimp_popup_key_press (GtkWidget *widget,
GdkEventKey *kevent)
{
- GtkBindingSet *binding_set;
-
- binding_set = gtk_binding_set_by_class (g_type_class_peek (GIMP_TYPE_POPUP));
+ GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (widget));
+ gboolean activate_binding = TRUE;
+
+ if (focus &&
+ (GTK_IS_EDITABLE (focus) ||
+ GTK_IS_TEXT_VIEW (focus)) &&
+ (kevent->keyval == GDK_KEY_space ||
+ kevent->keyval == GDK_KEY_KP_Space))
+ {
+ /* if a text widget has the focus, and the key was space,
+ * don't manually activate the binding to allow entering the
+ * space in the focus widget.
+ */
+ activate_binding = FALSE;
+ }
- /* invoke the popup's binding entries manually, because otherwise
- * the focus widget (GtkTreeView e.g.) would consume it
- */
- if (gtk_binding_set_activate (binding_set,
- kevent->keyval,
- kevent->state,
- GTK_OBJECT (widget)))
+ if (activate_binding)
{
- return TRUE;
+ GtkBindingSet *binding_set;
+
+ binding_set = gtk_binding_set_by_class (g_type_class_peek (GIMP_TYPE_POPUP));
+
+ /* invoke the popup's binding entries manually, because
+ * otherwise the focus widget (GtkTreeView e.g.) would consume
+ * it
+ */
+ if (gtk_binding_set_activate (binding_set,
+ kevent->keyval,
+ kevent->state,
+ GTK_OBJECT (widget)))
+ {
+ return TRUE;
+ }
}
return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, kevent);
diff --git a/app/widgets/gimpsearchpopup.c b/app/widgets/gimpsearchpopup.c
index bc5c0b8..90a5c92 100644
--- a/app/widgets/gimpsearchpopup.c
+++ b/app/widgets/gimpsearchpopup.c
@@ -124,7 +124,6 @@ gimp_search_popup_class_init (GimpSearchPopupClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpPopupClass *popup_class = GIMP_POPUP_CLASS (klass);
- GtkBindingSet *binding_set;
object_class->constructed = gimp_search_popup_constructed;
object_class->set_property = gimp_search_popup_set_property;
@@ -164,13 +163,6 @@ gimp_search_popup_class_init (GimpSearchPopupClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
- /* We don't want space to activate actions in the search widget, since
- * we allow search with spaces in it. */
- binding_set = gtk_binding_set_by_class (g_type_class_peek (GIMP_TYPE_POPUP));
-
- gtk_binding_entry_remove (binding_set, GDK_KEY_space, 0);
- gtk_binding_entry_remove (binding_set, GDK_KEY_KP_Space, 0);
-
g_type_class_add_private (klass, sizeof (GimpSearchPopupPrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]