[nautilus/wip/antoniof/post-gtk4-switch-fixes: 13/13] query-editor: Restore type-to-search




commit fd47742babfae904231efc7cb0d99afce5d37418
Author: António Fernandes <antoniof gnome org>
Date:   Thu Dec 23 17:35:23 2021 +0000

    query-editor: Restore type-to-search
    
    Use a temporary hack to fix the regression. It makes assumptions
    about the internals of GtkEntry, which are subject to change.
    
    We can drop this hack later, when we have custom tagged search entry.

 src/nautilus-query-editor.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 15bcd1f57..98d69f3b0 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -795,6 +795,7 @@ nautilus_query_editor_handle_event (NautilusQueryEditor   *self,
                                     guint                  keyval,
                                     GdkModifierType        state)
 {
+    GtkWidget *text;
     g_return_val_if_fail (NAUTILUS_IS_QUERY_EDITOR (self), GDK_EVENT_PROPAGATE);
     g_return_val_if_fail (controller != NULL, GDK_EVENT_PROPAGATE);
 
@@ -806,5 +807,19 @@ nautilus_query_editor_handle_event (NautilusQueryEditor   *self,
         return GDK_EVENT_PROPAGATE;
     }
 
-    return gtk_event_controller_key_forward (controller, GTK_WIDGET (self->entry));
+    text = gtk_widget_get_first_child (GTK_WIDGET (self->entry));
+    while (text != NULL)
+    {
+        if (GTK_IS_TEXT (text))
+        {
+            break;
+        }
+        text = gtk_widget_get_next_sibling (text);
+    }
+
+    if (text == NULL)
+    {
+        return FALSE;
+    }
+    return gtk_event_controller_key_forward (controller, text);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]