[nautilus/wip/antoniof/gtk4-preparation-step-container-api: 6/9] general: Stop using gtk_container_add()




commit 3ccecd7783eaf7137b9a3706fa297892dcd7b12d
Author: António Fernandes <antoniof gnome org>
Date:   Tue Nov 23 17:52:01 2021 +0000

    general: Stop using gtk_container_add()
    
    GtkContainer is gone in GTK4.
    
    Use per-class child-adding methods. For the cases where such methods
    are unavailable in GTK3, introduce small wrapper functions with the
    same signature as the GTK4 methods, to help with the transition.

 src/meson.build                     |  2 ++
 src/nautilus-canvas-view.c          |  5 +--
 src/nautilus-file-operations.c      |  3 +-
 src/nautilus-files-view.c           |  5 +--
 src/nautilus-floating-bar.c         |  7 ++--
 src/nautilus-gtk4-helpers.c         | 65 +++++++++++++++++++++++++++++++++++++
 src/nautilus-gtk4-helpers.h         | 26 +++++++++++++++
 src/nautilus-list-view.c            |  4 ++-
 src/nautilus-places-view.c          |  2 +-
 src/nautilus-query-editor.c         |  9 ++---
 src/nautilus-search-popover.c       | 13 ++++----
 src/nautilus-special-location-bar.c |  7 ++--
 src/nautilus-toolbar.c              | 17 +++++-----
 src/nautilus-trash-bar.c            |  8 ++---
 src/nautilus-window-slot.c          | 11 ++++---
 src/nautilus-window.c               |  9 ++---
 src/nautilus-x-content-bar.c        |  7 ++--
 17 files changed, 151 insertions(+), 49 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index f1948160b..682d6f3a3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -65,6 +65,8 @@ libnautilus_sources = [
   'gtk/nautilusgtkplacesviewprivate.h',
   'gtk/nautilusgtkplacesviewrow.c',
   'gtk/nautilusgtkplacesviewrowprivate.h',
+  'nautilus-gtk4-helpers.c',
+  'nautilus-gtk4-helpers.h',
   'nautilus-application.c',
   'nautilus-application.h',
   'nautilus-bookmark-list.c',
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index c4e747e3c..ce162d414 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -44,6 +44,7 @@
 #include "nautilus-canvas-dnd.h"
 #include "nautilus-metadata.h"
 #include "nautilus-clipboard.h"
+#include "nautilus-gtk4-helpers.h"
 
 #define DEBUG_FLAG NAUTILUS_DEBUG_CANVAS_VIEW
 #include "nautilus-debug.h"
@@ -1413,8 +1414,8 @@ initialize_canvas_container (NautilusCanvasView      *canvas_view,
     g_signal_connect_object (canvas_container, "get-container-uri",
                              G_CALLBACK (canvas_view_get_container_uri), canvas_view, 0);
 
-    gtk_container_add (GTK_CONTAINER (content_widget),
-                       GTK_WIDGET (canvas_container));
+    gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (content_widget),
+                                   GTK_WIDGET (canvas_container));
 
     nautilus_canvas_view_update_click_mode (canvas_view);
     nautilus_canvas_container_set_zoom_level (canvas_container,
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index d6f998d61..2951af898 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -59,6 +59,7 @@
 #include "nautilus-file-undo-operations.h"
 #include "nautilus-file-undo-manager.h"
 #include "nautilus-ui-utilities.h"
+#include "nautilus-gtk4-helpers.h"
 
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
@@ -1362,7 +1363,7 @@ do_run_simple_dialog (gpointer _data)
         gtk_label_set_max_width_chars (GTK_LABEL (label),
                                        MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
 
-        gtk_container_add (GTK_CONTAINER (content_area), label);
+        gtk_box_append (GTK_BOX (content_area), label);
 
         gtk_widget_show (label);
     }
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index da291b81d..4216d37b7 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -89,6 +89,7 @@
 #include "nautilus-view-icon-controller.h"
 #include "nautilus-window.h"
 #include "nautilus-tracker-utilities.h"
+#include "nautilus-gtk4-helpers.h"
 
 #ifdef HAVE_LIBPORTAL
 #include <libportal/portal.h>
@@ -9870,7 +9871,7 @@ nautilus_files_view_init (NautilusFilesView *view)
     priv->overlay = gtk_overlay_new ();
     gtk_widget_set_vexpand (priv->overlay, TRUE);
     gtk_widget_set_hexpand (priv->overlay, TRUE);
-    gtk_container_add (GTK_CONTAINER (view), priv->overlay);
+    gtk_grid_attach_next_to (GTK_GRID (view), priv->overlay, NULL, GTK_POS_BOTTOM, 1, 1);
     gtk_widget_show (priv->overlay);
 
     /* NautilusFloatingBar listen to its parent's 'event' signal
@@ -9896,7 +9897,7 @@ nautilus_files_view_init (NautilusFilesView *view)
                               G_CALLBACK (popup_menu_callback),
                               view);
 
-    gtk_container_add (GTK_CONTAINER (priv->overlay), priv->scrolled_window);
+    gtk_overlay_set_child (GTK_OVERLAY (priv->overlay), priv->scrolled_window);
 
     /* Empty states */
     builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-no-search-results.ui");
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
index 55a29a52e..4d166d4d8 100644
--- a/src/nautilus-floating-bar.c
+++ b/src/nautilus-floating-bar.c
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include "nautilus-floating-bar.h"
+#include "nautilus-gtk4-helpers.h"
 
 #define HOVER_HIDE_TIMEOUT_INTERVAL 100
 
@@ -435,13 +436,13 @@ nautilus_floating_bar_constructed (GObject *obj)
     w = gtk_label_new (NULL);
     gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
     gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
-    gtk_container_add (GTK_CONTAINER (labels_box), w);
+    gtk_box_append (GTK_BOX (labels_box), w);
     self->primary_label_widget = w;
     gtk_widget_show (w);
 
     w = gtk_label_new (NULL);
     gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
-    gtk_container_add (GTK_CONTAINER (labels_box), w);
+    gtk_box_append (GTK_BOX (labels_box), w);
     self->details_label_widget = w;
     gtk_widget_show (w);
 
@@ -450,7 +451,7 @@ nautilus_floating_bar_constructed (GObject *obj)
     gtk_style_context_add_class (context, "circular");
     gtk_style_context_add_class (context, "flat");
     gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
-    gtk_container_add (GTK_CONTAINER (self), w);
+    gtk_box_append (GTK_BOX (self), w);
     self->stop_button = w;
     gtk_widget_set_visible (w, FALSE);
     gtk_widget_set_no_show_all (w, TRUE);
diff --git a/src/nautilus-gtk4-helpers.c b/src/nautilus-gtk4-helpers.c
new file mode 100644
index 000000000..50ee263e5
--- /dev/null
+++ b/src/nautilus-gtk4-helpers.c
@@ -0,0 +1,65 @@
+#include "nautilus-gtk4-helpers.h"
+
+void
+gtk_button_set_child (GtkButton *button,
+                      GtkWidget *child)
+{
+    g_assert (GTK_IS_BUTTON (button));
+
+    gtk_container_add (GTK_CONTAINER (button), child);
+}
+
+void
+gtk_box_append (GtkBox    *box,
+                GtkWidget *child)
+{
+    g_assert (GTK_IS_BOX (box));
+
+    gtk_container_add (GTK_CONTAINER (box), child);
+}
+
+void
+gtk_overlay_set_child (GtkOverlay *overlay,
+                       GtkWidget  *child)
+{
+    g_assert (GTK_IS_OVERLAY (overlay));
+
+    gtk_container_add (GTK_CONTAINER (overlay), child);
+}
+
+void
+gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
+                               GtkWidget         *child)
+{
+    g_assert (GTK_IS_SCROLLED_WINDOW (scrolled_window));
+
+    gtk_container_add (GTK_CONTAINER (scrolled_window), child);
+}
+
+void
+gtk_list_box_row_set_child (GtkListBoxRow *row,
+                            GtkWidget     *child)
+{
+    g_assert (GTK_IS_LIST_BOX_ROW (row));
+
+    gtk_container_add (GTK_CONTAINER (row), child);
+}
+
+void
+gtk_info_bar_add_child (GtkInfoBar *info_bar,
+                        GtkWidget  *widget)
+{
+    g_assert (GTK_IS_INFO_BAR (info_bar));
+
+    gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (info_bar)),
+                       widget);
+}
+
+void
+gtk_revealer_set_child (GtkRevealer *revealer,
+                        GtkWidget   *child)
+{
+    g_assert (GTK_IS_REVEALER (revealer));
+
+    gtk_container_add (GTK_CONTAINER (revealer), child);
+}
diff --git a/src/nautilus-gtk4-helpers.h b/src/nautilus-gtk4-helpers.h
new file mode 100644
index 000000000..b245f1dd6
--- /dev/null
+++ b/src/nautilus-gtk4-helpers.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+#if GTK_MAJOR_VERSION < 4
+
+void gtk_button_set_child          (GtkButton         *button,
+                                    GtkWidget         *child);
+void gtk_box_append                (GtkBox            *box,
+                                    GtkWidget         *child);
+void gtk_overlay_set_child         (GtkOverlay        *overlay,
+                                    GtkWidget         *child);
+void gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
+                                    GtkWidget         *child);
+void gtk_list_box_row_set_child    (GtkListBoxRow     *row,
+                                    GtkWidget         *child);
+void gtk_info_bar_add_child        (GtkInfoBar        *info_bar,
+                                    GtkWidget         *widget);
+void gtk_revealer_set_child        (GtkRevealer       *revealer,
+                                    GtkWidget         *child);
+
+#endif
+G_END_DECLS
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 9e91b62a2..1df7223b0 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -55,6 +55,7 @@
 #include "nautilus-ui-utilities.h"
 #include "nautilus-view.h"
 #include "nautilus-tracker-utilities.h"
+#include "nautilus-gtk4-helpers.h"
 
 struct SelectionForeachData
 {
@@ -2417,7 +2418,8 @@ create_and_set_up_tree_view (NautilusListView *view)
                             default_visible_columns);
 
     gtk_widget_show (GTK_WIDGET (view->details->tree_view));
-    gtk_container_add (GTK_CONTAINER (content_widget), GTK_WIDGET (view->details->tree_view));
+    gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (content_widget),
+                                   GTK_WIDGET (view->details->tree_view));
 
     atk_obj = gtk_widget_get_accessible (GTK_WIDGET (view->details->tree_view));
     atk_object_set_name (atk_obj, _("List View"));
diff --git a/src/nautilus-places-view.c b/src/nautilus-places-view.c
index 06643af73..732f4fd51 100644
--- a/src/nautilus-places-view.c
+++ b/src/nautilus-places-view.c
@@ -397,7 +397,7 @@ nautilus_places_view_init (NautilusPlacesView *self)
     gtk_widget_set_hexpand (priv->places_view, TRUE);
     gtk_widget_set_vexpand (priv->places_view, TRUE);
     gtk_widget_show (priv->places_view);
-    gtk_container_add (GTK_CONTAINER (self), priv->places_view);
+    gtk_grid_attach_next_to (GTK_GRID (self), priv->places_view, NULL, GTK_POS_BOTTOM, 1, 1);
 
     g_signal_connect_swapped (priv->places_view,
                               "notify::loading",
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 1eb074927..05d2565bd 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -36,6 +36,7 @@
 #include "nautilus-search-popover.h"
 #include "nautilus-mime-actions.h"
 #include "nautilus-ui-utilities.h"
+#include "nautilus-gtk4-helpers.h"
 
 struct _NautilusQueryEditor
 {
@@ -557,18 +558,18 @@ setup_widgets (NautilusQueryEditor *editor)
 
     /* vertical box that holds the search entry and the label below */
     vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-    gtk_container_add (GTK_CONTAINER (editor), vbox);
+    gtk_box_append (GTK_BOX (editor), vbox);
 
     /* horizontal box */
     hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
     gtk_style_context_add_class (gtk_widget_get_style_context (hbox), "linked");
-    gtk_container_add (GTK_CONTAINER (vbox), hbox);
+    gtk_box_append (GTK_BOX (vbox), hbox);
 
     /* create the search entry */
     editor->entry = GTK_WIDGET (gd_tagged_entry_new ());
     gtk_widget_set_hexpand (editor->entry, TRUE);
 
-    gtk_container_add (GTK_CONTAINER (hbox), editor->entry);
+    gtk_box_append (GTK_BOX (hbox), editor->entry);
 
     editor->mime_types_tag = gd_tagged_entry_tag_new (NULL);
     editor->date_range_tag = gd_tagged_entry_tag_new (NULL);
@@ -597,7 +598,7 @@ setup_widgets (NautilusQueryEditor *editor)
     /* setup the filter menu button */
     editor->dropdown_button = gtk_menu_button_new ();
     gtk_menu_button_set_popover (GTK_MENU_BUTTON (editor->dropdown_button), editor->popover);
-    gtk_container_add (GTK_CONTAINER (hbox), editor->dropdown_button);
+    gtk_box_append (GTK_BOX (hbox), editor->dropdown_button);
 
     g_signal_connect (editor->entry, "activate",
                       G_CALLBACK (entry_activate_cb), editor);
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index d823cdbb9..0ca3e487a 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -24,6 +24,7 @@
 #include "nautilus-file.h"
 #include "nautilus-ui-utilities.h"
 #include "nautilus-global-preferences.h"
+#include "nautilus-gtk4-helpers.h"
 
  #define SEARCH_FILTER_MAX_YEARS 5
 
@@ -399,7 +400,7 @@ create_row_for_label (const gchar *text,
                           "margin-start", 6,
                           NULL);
 
-    gtk_container_add (GTK_CONTAINER (row), label);
+    gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), label);
     gtk_widget_show_all (row);
 
     return row;
@@ -421,7 +422,7 @@ fill_fuzzy_dates_listbox (NautilusSearchPopover *popover)
 
     /* Add the no date filter element first */
     row = create_row_for_label (_("Any time"), TRUE);
-    gtk_container_add (GTK_CONTAINER (popover->dates_listbox), row);
+    gtk_list_box_insert (GTK_LIST_BOX (popover->dates_listbox), row, -1);
 
     /* This is a tricky loop. The main intention here is that each
      * timeslice (day, week, month) have 2 or 3 entries.
@@ -483,7 +484,7 @@ fill_fuzzy_dates_listbox (NautilusSearchPopover *popover)
                                 g_date_time_ref (current_date),
                                 (GDestroyNotify) g_date_time_unref);
 
-        gtk_container_add (GTK_CONTAINER (popover->dates_listbox), row);
+        gtk_list_box_insert (GTK_LIST_BOX (popover->dates_listbox), row, -1);
 
         g_free (label);
         g_date_time_unref (current_date);
@@ -513,13 +514,13 @@ fill_types_listbox (NautilusSearchPopover *popover)
         row = create_row_for_label (nautilus_mime_types_group_get_name (i), i == 3);
         g_object_set_data (G_OBJECT (row), "mimetype-group", GINT_TO_POINTER (i));
 
-        gtk_container_add (GTK_CONTAINER (popover->type_listbox), row);
+        gtk_list_box_insert (GTK_LIST_BOX (popover->type_listbox), row, -1);
     }
 
     /* Other types */
     row = create_row_for_label (_("Other Type…"), TRUE);
     g_object_set_data (G_OBJECT (row), "mimetype-group", GINT_TO_POINTER (-1));
-    gtk_container_add (GTK_CONTAINER (popover->type_listbox), row);
+    gtk_list_box_insert (GTK_LIST_BOX (popover->type_listbox), row, -1);
 }
 
 static void
@@ -612,7 +613,7 @@ show_other_types_dialog (NautilusSearchPopover *popover)
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
 
     gtk_widget_show (treeview);
-    gtk_container_add (GTK_CONTAINER (scrolled), treeview);
+    gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), treeview);
 
     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
     {
diff --git a/src/nautilus-special-location-bar.c b/src/nautilus-special-location-bar.c
index 2c2ce0759..ce4052122 100644
--- a/src/nautilus-special-location-bar.c
+++ b/src/nautilus-special-location-bar.c
@@ -24,6 +24,7 @@
 
 #include "nautilus-special-location-bar.h"
 #include "nautilus-enum-types.h"
+#include "nautilus-gtk4-helpers.h"
 
 struct _NautilusSpecialLocationBar
 {
@@ -162,11 +163,9 @@ nautilus_special_location_bar_class_init (NautilusSpecialLocationBarClass *klass
 static void
 nautilus_special_location_bar_init (NautilusSpecialLocationBar *bar)
 {
-    GtkWidget *location_area;
     GtkWidget *action_area;
     PangoAttrList *attrs;
 
-    location_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
     action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
 
     gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
@@ -178,12 +177,12 @@ nautilus_special_location_bar_init (NautilusSpecialLocationBar *bar)
     pango_attr_list_unref (attrs);
 
     gtk_label_set_ellipsize (GTK_LABEL (bar->label), PANGO_ELLIPSIZE_END);
-    gtk_container_add (GTK_CONTAINER (location_area), bar->label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), bar->label);
 
     bar->learn_more_label = gtk_label_new (NULL);
     gtk_widget_set_hexpand (bar->learn_more_label, TRUE);
     gtk_widget_set_halign (bar->learn_more_label, GTK_ALIGN_END);
-    gtk_container_add (GTK_CONTAINER (location_area), bar->learn_more_label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), bar->learn_more_label);
 }
 
 GtkWidget *
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 0addb85a6..811a774cd 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -40,6 +40,7 @@
 #include "nautilus-toolbar-menu-sections.h"
 #include "nautilus-ui-utilities.h"
 #include "nautilus-window.h"
+#include "nautilus-gtk4-helpers.h"
 
 #define OPERATION_MINIMUM_TIME 2 /*s */
 #define NEEDS_ATTENTION_ANIMATION_TIMEOUT 2000 /*ms */
@@ -900,16 +901,16 @@ nautilus_toolbar_constructed (GObject *object)
     NautilusToolbar *self = NAUTILUS_TOOLBAR (object);
 
     self->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
-    gtk_container_add (GTK_CONTAINER (self->path_bar_container),
-                       self->path_bar);
+    gtk_box_append (GTK_BOX (self->path_bar_container),
+                    self->path_bar);
 
     self->location_entry = nautilus_location_entry_new ();
-    gtk_container_add (GTK_CONTAINER (self->location_entry_container),
-                       self->location_entry);
+    gtk_box_append (GTK_BOX (self->location_entry_container),
+                    self->location_entry);
     self->location_entry_close_button = gtk_button_new_from_icon_name ("window-close-symbolic",
                                                                        GTK_ICON_SIZE_BUTTON);
-    gtk_container_add (GTK_CONTAINER (self->location_entry_container),
-                       self->location_entry_close_button);
+    gtk_box_append (GTK_BOX (self->location_entry_container),
+                    self->location_entry_close_button);
     g_signal_connect (self->location_entry_close_button, "clicked",
                       G_CALLBACK (on_location_entry_close), self);
 
@@ -1468,8 +1469,8 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar    *self,
 
     if (self->window_slot != NULL)
     {
-        gtk_container_add (GTK_CONTAINER (self->search_container),
-                           GTK_WIDGET (nautilus_window_slot_get_query_editor (self->window_slot)));
+        gtk_box_append (GTK_BOX (self->search_container),
+                        GTK_WIDGET (nautilus_window_slot_get_query_editor (self->window_slot)));
     }
 
     toolbar_update_appearance (self);
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index 7fca03e67..4f19bdfaa 100644
--- a/src/nautilus-trash-bar.c
+++ b/src/nautilus-trash-bar.c
@@ -32,6 +32,7 @@
 #include "nautilus-file.h"
 #include "nautilus-trash-monitor.h"
 #include "nautilus-ui-utilities.h"
+#include "nautilus-gtk4-helpers.h"
 
 enum
 {
@@ -211,13 +212,12 @@ trash_bar_response_cb (GtkInfoBar *infobar,
 static void
 nautilus_trash_bar_init (NautilusTrashBar *bar)
 {
-    GtkWidget *content_area, *action_area, *w;
+    GtkWidget *action_area, *w;
     const gchar *subtitle_text;
     GtkWidget *label;
     GtkWidget *subtitle;
     PangoAttrList *attrs;
 
-    content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
     action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
 
     gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area),
@@ -241,9 +241,9 @@ nautilus_trash_bar_init (NautilusTrashBar *bar)
                      G_SETTINGS_BIND_GET);
 
     gtk_widget_show (label);
-    gtk_container_add (GTK_CONTAINER (content_area), label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), label);
 
-    gtk_container_add (GTK_CONTAINER (content_area), subtitle);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), subtitle);
 
     w = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
                                  _("_Settings"),
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 4f93f67c8..4e834e8aa 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -48,6 +48,7 @@
 #include <nautilus-extension.h>
 #include "nautilus-ui-utilities.h"
 #include <eel/eel-vfs-extensions.h>
+#include "nautilus-gtk4-helpers.h"
 
 enum
 {
@@ -925,10 +926,10 @@ nautilus_window_slot_constructed (GObject *object)
     self->search_info_label = GTK_LABEL (gtk_label_new (NULL));
     self->search_info_label_revealer = GTK_REVEALER (gtk_revealer_new ());
 
-    gtk_container_add (GTK_CONTAINER (self->search_info_label_revealer),
-                       GTK_WIDGET (self->search_info_label));
-    gtk_container_add (GTK_CONTAINER (self),
-                       GTK_WIDGET (self->search_info_label_revealer));
+    gtk_revealer_set_child (GTK_REVEALER (self->search_info_label_revealer),
+                            GTK_WIDGET (self->search_info_label));
+    gtk_box_append (GTK_BOX (self),
+                    GTK_WIDGET (self->search_info_label_revealer));
 
     gtk_widget_show (GTK_WIDGET (self->search_info_label));
     gtk_widget_show (GTK_WIDGET (self->search_info_label_revealer));
@@ -2854,7 +2855,7 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
         self->new_content_view = NULL;
 
         widget = GTK_WIDGET (self->content_view);
-        gtk_container_add (GTK_CONTAINER (self), widget);
+        gtk_box_append (GTK_BOX (self), widget);
         gtk_widget_set_vexpand (widget, TRUE);
         gtk_widget_show (widget);
         self->searching_binding = g_object_bind_property (self->content_view, "searching",
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index d60db7e3a..62c0e62b9 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -69,6 +69,7 @@
 #include "nautilus-trash-monitor.h"
 #include "nautilus-ui-utilities.h"
 #include "nautilus-window-slot.h"
+#include "nautilus-gtk4-helpers.h"
 
 /* Forward and back buttons on the mouse */
 static gboolean mouse_extra_buttons = TRUE;
@@ -1207,7 +1208,7 @@ add_menu_separator (GtkWidget *menu)
     GtkWidget *separator;
 
     separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
-    gtk_container_add (GTK_CONTAINER (menu), separator);
+    gtk_box_append (GTK_BOX (menu), separator);
     gtk_widget_show (separator);
 }
 
@@ -1237,7 +1238,7 @@ places_sidebar_populate_popup_cb (GtkPlacesSidebar *sidebar,
             gtk_actionable_set_action_name (GTK_ACTIONABLE (menu_item),
                                             "win.empty-trash");
             g_object_set (menu_item, "text", _("Empty _Trash…"), NULL);
-            gtk_container_add (GTK_CONTAINER (menu), menu_item);
+            gtk_box_append (GTK_BOX (menu), menu_item);
             gtk_widget_show (menu_item);
 
             action = g_action_map_lookup_action (G_ACTION_MAP (window),
@@ -1256,7 +1257,7 @@ places_sidebar_populate_popup_cb (GtkPlacesSidebar *sidebar,
             gtk_actionable_set_action_name (GTK_ACTIONABLE (menu_item),
                                             "win.properties");
             g_object_set (menu_item, "text", _("_Properties"), NULL);
-            gtk_container_add (GTK_CONTAINER (menu), menu_item);
+            gtk_box_append (GTK_BOX (menu), menu_item);
             gtk_widget_show (menu_item);
         }
     }
@@ -1272,7 +1273,7 @@ places_sidebar_populate_popup_cb (GtkPlacesSidebar *sidebar,
             {
                 window->selected_volume = g_object_ref (selected_volume);
             }
-            gtk_container_add (GTK_CONTAINER (menu), menu_item);
+            gtk_box_append (GTK_BOX (menu), menu_item);
             gtk_widget_show (menu_item);
 
             action = g_action_map_lookup_action (G_ACTION_MAP (window),
diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c
index a7bbce15e..2613cff46 100644
--- a/src/nautilus-x-content-bar.c
+++ b/src/nautilus-x-content-bar.c
@@ -30,6 +30,7 @@
 #include "nautilus-icon-info.h"
 #include "nautilus-file-utilities.h"
 #include "nautilus-program-choosing.h"
+#include "nautilus-gtk4-helpers.h"
 
 struct _NautilusXContentBar
 {
@@ -197,7 +198,7 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar,
         }
         gtk_box_pack_start (GTK_BOX (box), gtk_label_new (name), FALSE, FALSE, 0);
 
-        gtk_container_add (GTK_CONTAINER (button), box);
+        gtk_button_set_child (GTK_BUTTON (button), box);
 
         gtk_widget_show (button);
     }
@@ -322,11 +323,9 @@ nautilus_x_content_bar_class_init (NautilusXContentBarClass *klass)
 static void
 nautilus_x_content_bar_init (NautilusXContentBar *bar)
 {
-    GtkWidget *content_area;
     GtkWidget *action_area;
     PangoAttrList *attrs;
 
-    content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
     action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (bar));
 
     gtk_orientable_set_orientation (GTK_ORIENTABLE (action_area), GTK_ORIENTATION_HORIZONTAL);
@@ -338,7 +337,7 @@ nautilus_x_content_bar_init (NautilusXContentBar *bar)
     pango_attr_list_unref (attrs);
 
     gtk_label_set_ellipsize (GTK_LABEL (bar->label), PANGO_ELLIPSIZE_END);
-    gtk_container_add (GTK_CONTAINER (content_area), bar->label);
+    gtk_info_bar_add_child (GTK_INFO_BAR (bar), bar->label);
 
     g_signal_connect (bar, "response",
                       G_CALLBACK (content_bar_response_cb),


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