[nautilus/wip/antoniof/switch-to-gtk4: 29/37] -- WIP -- must focus




commit 6e12580080dc0e687b282e2fa19106ef89590b12
Author: António Fernandes <antoniof gnome org>
Date:   Fri Dec 24 00:59:41 2021 +0000

    -- WIP -- must focus

 src/nautilus-files-view.c   | 12 ++++++++----
 src/nautilus-query-editor.c | 18 ++++++++++++++----
 src/nautilus-window-slot.c  | 20 +++++++++++++-------
 src/nautilus-window.c       | 11 ++++++++---
 4 files changed, 43 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index c7a464066..61dae0f97 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3120,7 +3120,7 @@ slot_active_changed (NautilusWindowSlot *slot,
     }
 }
 
-static void
+static gboolean
 nautilus_files_view_grab_focus (GtkWidget *widget)
 {
     /* focus the child of the scrolled window if it exists */
@@ -3128,16 +3128,20 @@ nautilus_files_view_grab_focus (GtkWidget *widget)
     NautilusFilesViewPrivate *priv;
     GtkWidget *child;
 
+    if (GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->grab_focus (widget))
+    {
+        return TRUE;
+    }
+
     view = NAUTILUS_FILES_VIEW (widget);
     priv = nautilus_files_view_get_instance_private (view);
     child = gtk_scrolled_window_get_child (GTK_SCROLLED_WINDOW (priv->scrolled_window));
 
-    GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->grab_focus (widget);
-
     if (child)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (child));
+        return gtk_widget_grab_focus (GTK_WIDGET (child));
     }
+    return FALSE;
 }
 
 static void
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 8b2549ea6..dcb6e5e59 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -145,19 +145,29 @@ nautilus_query_editor_dispose (GObject *object)
     G_OBJECT_CLASS (nautilus_query_editor_parent_class)->dispose (object);
 }
 
-static void
+static gboolean
 nautilus_query_editor_grab_focus (GtkWidget *widget)
 {
     NautilusQueryEditor *editor;
 
     editor = NAUTILUS_QUERY_EDITOR (widget);
 
-    if (gtk_widget_get_visible (widget) && !gtk_widget_is_focus (editor->entry))
+    if (GTK_WIDGET_CLASS (nautilus_query_editor_parent_class)->grab_focus (widget))
+    {
+        return TRUE;
+    }
+
+    if (gtk_widget_get_visible (widget))
     {
         /* avoid selecting the entry text */
-        gtk_widget_grab_focus (editor->entry);
-        gtk_editable_set_position (GTK_EDITABLE (editor->entry), -1);
+        if (gtk_widget_grab_focus (editor->entry))
+        {
+            gtk_editable_set_position (GTK_EDITABLE (editor->entry), -1);
+            return TRUE;
+        }
     }
+
+    return FALSE;
 }
 
 static void
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index bf9fa156c..8a613f22c 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2944,25 +2944,31 @@ nautilus_window_slot_finalize (GObject *object)
     G_OBJECT_CLASS (nautilus_window_slot_parent_class)->finalize (object);
 }
 
-static void
+static gboolean
 nautilus_window_slot_grab_focus (GtkWidget *widget)
 {
     NautilusWindowSlot *self;
     self = NAUTILUS_WINDOW_SLOT (widget);
-    GTK_WIDGET_CLASS (nautilus_window_slot_parent_class)->grab_focus (widget);
+
+    if (GTK_WIDGET_CLASS (nautilus_window_slot_parent_class)->grab_focus (widget))
+    {
+        return TRUE;
+    }
 
     if (nautilus_window_slot_get_search_visible (self))
     {
-        gtk_widget_grab_focus (GTK_WIDGET (self->query_editor));
+        return gtk_widget_grab_focus (GTK_WIDGET (self->query_editor));
     }
-    else if (self->content_view)
+    if (self->content_view)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (self->content_view));
+        return gtk_widget_grab_focus (GTK_WIDGET (self->content_view));
     }
-    else if (self->new_content_view)
+    if (self->new_content_view)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (self->new_content_view));
+        return gtk_widget_grab_focus (GTK_WIDGET (self->new_content_view));
     }
+
+    return FALSE;
 }
 
 static void
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index ded98fba1..0ed906572 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -632,19 +632,24 @@ remember_focus_widget (NautilusWindow *window)
     }
 }
 
-static void
+static gboolean
 nautilus_window_grab_focus (GtkWidget *widget)
 {
     NautilusWindowSlot *slot;
 
     slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (widget));
 
-    GTK_WIDGET_CLASS (nautilus_window_parent_class)->grab_focus (widget);
+    if (GTK_WIDGET_CLASS (nautilus_window_parent_class)->grab_focus (widget))
+    {
+        return TRUE;
+    }
 
     if (slot)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (slot));
+        return gtk_widget_grab_focus (GTK_WIDGET (slot));
     }
+
+    return FALSE;
 }
 
 static void


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