[nautilus/wip/antoniof/switch-to-gtk4: 14/22] general: Adapt to GtkWidget.grab_focus() changes




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

    general: Adapt to GtkWidget.grab_focus() changes
    
    It returns a boolean now. Forwarding the returned boolean requires us
    to rearrange the order of some instructions.

 src/nautilus-files-view.c   | 10 +++++-----
 src/nautilus-query-editor.c |  7 ++++---
 src/nautilus-window-slot.c  | 15 ++++++++-------
 src/nautilus-window.c       | 10 +++++-----
 4 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 7ba3f7084..4b489eea5 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 */
@@ -3132,12 +3132,12 @@ nautilus_files_view_grab_focus (GtkWidget *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)
+    if (child != NULL)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (child));
+        return gtk_widget_grab_focus (GTK_WIDGET (child));
     }
+
+    return GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->grab_focus (widget);
 }
 
 static void
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 8b2549ea6..ab1475fcb 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -145,7 +145,7 @@ 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;
@@ -155,9 +155,10 @@ nautilus_query_editor_grab_focus (GtkWidget *widget)
     if (gtk_widget_get_visible (widget) && !gtk_widget_is_focus (editor->entry))
     {
         /* avoid selecting the entry text */
-        gtk_widget_grab_focus (editor->entry);
-        gtk_editable_set_position (GTK_EDITABLE (editor->entry), -1);
+        return gtk_entry_grab_focus_without_selecting (GTK_ENTRY (editor->entry));
     }
+
+    return FALSE;
 }
 
 static void
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index bf9fa156c..7e94ffcab 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2944,25 +2944,26 @@ 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 (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)
+    else if (self->content_view != NULL)
     {
-        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)
+    else if (self->new_content_view != NULL)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (self->new_content_view));
+        return gtk_widget_grab_focus (GTK_WIDGET (self->new_content_view));
     }
+
+    return GTK_WIDGET_CLASS (nautilus_window_slot_parent_class)->grab_focus (widget);
 }
 
 static void
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 51924dd79..2518e045c 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -632,19 +632,19 @@ 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 (slot)
+    if (slot != NULL)
     {
-        gtk_widget_grab_focus (GTK_WIDGET (slot));
+        return gtk_widget_grab_focus (GTK_WIDGET (slot));
     }
+
+    return GTK_WIDGET_CLASS (nautilus_window_parent_class)->grab_focus (widget);
 }
 
 static void


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