[nautilus/wip/antoniof/gtk4-preparation-discontinued-api: 30/32] view-icon-controller: Stop using gtk_container_get_focus_child()




commit 77d5eb428e1c17192721b508fe56d29c734a656b
Author: António Fernandes <antoniof gnome org>
Date:   Sat Jan 1 19:26:53 2022 +0000

    view-icon-controller: Stop using gtk_container_get_focus_child()
    
    Use a wrapper that mocks of the GTK 4 API

 src/nautilus-gtk4-helpers.c         | 8 ++++++++
 src/nautilus-gtk4-helpers.h         | 1 +
 src/nautilus-view-icon-controller.c | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-gtk4-helpers.c b/src/nautilus-gtk4-helpers.c
index d48358615..78071ee43 100644
--- a/src/nautilus-gtk4-helpers.c
+++ b/src/nautilus-gtk4-helpers.c
@@ -98,6 +98,14 @@ gtk_widget_get_first_child (GtkWidget *widget)
     return NULL;
 }
 
+GtkWidget *
+gtk_widget_get_focus_child (GtkWidget *widget)
+{
+    g_assert (GTK_IS_CONTAINER (widget));
+
+    return gtk_container_get_focus_child (GTK_CONTAINER (widget));
+}
+
 GtkWidget *
 gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled)
 {
diff --git a/src/nautilus-gtk4-helpers.h b/src/nautilus-gtk4-helpers.h
index 4ceb606f7..4f269afda 100644
--- a/src/nautilus-gtk4-helpers.h
+++ b/src/nautilus-gtk4-helpers.h
@@ -27,6 +27,7 @@ void gtk_revealer_set_child        (GtkRevealer       *revealer,
                                     GtkWidget         *child);
 
 GtkWidget *gtk_widget_get_first_child (GtkWidget *widget);
+GtkWidget *gtk_widget_get_focus_child (GtkWidget *widget);
 GtkWidget *gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled);
 
 void gtk_style_context_add_provider_for_display    (GdkDisplay       *display,
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index df4d96f04..98599862c 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -9,6 +9,7 @@
 #include "nautilus-directory.h"
 #include "nautilus-global-preferences.h"
 #include "nautilus-thumbnails.h"
+#include "nautilus-gtk4-helpers.h"
 
 struct _NautilusViewIconController
 {
@@ -718,7 +719,7 @@ real_reveal_for_selection_context_menu (NautilusFilesView *files_view)
 
     /* Get the focused item_ui, if selected.
      * Otherwise, get the selected item_ui which is sorted the lowest.*/
-    item_ui = gtk_container_get_focus_child (GTK_CONTAINER (self->view_ui));
+    item_ui = gtk_widget_get_focus_child (GTK_WIDGET (self->view_ui));
     if (item_ui == NULL || !gtk_flow_box_child_is_selected (GTK_FLOW_BOX_CHILD (item_ui)))
     {
         g_autoptr (GList) list = gtk_flow_box_get_selected_children (self->view_ui);


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