[nautilus/wip/toolbar-start-end: 72/77] toolbar: Factor out history controls




commit eb3aecdc3796ccc90ded1d04dab68a94f41e34df
Author: Christopher Davis <christopherdavis gnome org>
Date:   Wed Jul 20 21:31:46 2022 -0400

    toolbar: Factor out history controls
    
    In order to adapt to narrow window sizes, we need to be be able to
    show the same controls in different places, but we don't want to
    duplicate the code or the UI definitions.
    
    Thus, we should encapsulate the code and logic we need into distinct
    reusable components.
    
    Start with the back and forward buttons, along with their context menu.
    They will update their state properly through bindings without needing
    to call any functions ourselves.

 src/meson.build                               |   2 +
 src/nautilus-history-controls.c               | 313 ++++++++++++++++++++++++++
 src/nautilus-history-controls.h               |  20 ++
 src/nautilus-toolbar.c                        | 175 +-------------
 src/resources/nautilus.gresource.xml          |   1 +
 src/resources/ui/nautilus-history-controls.ui |  28 +++
 src/resources/ui/nautilus-toolbar.ui          |  38 ++--
 7 files changed, 381 insertions(+), 196 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index c28faa8a2..6a1e21f28 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -89,6 +89,8 @@ libnautilus_sources = [
   'nautilus-grid-cell.h',
   'nautilus-grid-view.c',
   'nautilus-grid-view.h',
+  'nautilus-history-controls.c',
+  'nautilus-history-controls.h',
   'nautilus-label-cell.c',
   'nautilus-label-cell.h',
   'nautilus-list-base.c',
diff --git a/src/nautilus-history-controls.c b/src/nautilus-history-controls.c
new file mode 100644
index 000000000..8b14cd63c
--- /dev/null
+++ b/src/nautilus-history-controls.c
@@ -0,0 +1,313 @@
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "nautilus-history-controls.h"
+
+#include "nautilus-bookmark.h"
+#include "nautilus-window.h"
+
+struct _NautilusHistoryControls
+{
+    AdwBin parent_instance;
+
+    GtkWidget *back_button;
+    GtkWidget *back_menu;
+
+    GtkWidget *forward_button;
+    GtkWidget *forward_menu;
+
+    NautilusWindowSlot *window_slot;
+};
+
+G_DEFINE_FINAL_TYPE (NautilusHistoryControls, nautilus_history_controls, ADW_TYPE_BIN)
+
+enum
+{
+    PROP_0,
+    PROP_WINDOW_SLOT,
+    N_PROPS
+};
+
+static GParamSpec *properties[N_PROPS];
+
+static void
+fill_menu (NautilusHistoryControls *self,
+           GMenu                   *menu,
+           gboolean                 back)
+{
+    guint index;
+    GList *list;
+    const gchar *name;
+
+    list = back ? nautilus_window_slot_get_back_history (self->window_slot) :
+           nautilus_window_slot_get_forward_history (self->window_slot);
+
+    index = 0;
+    while (list != NULL)
+    {
+        g_autoptr (GMenuItem) item = NULL;
+
+        name = nautilus_bookmark_get_name (NAUTILUS_BOOKMARK (list->data));
+        item = g_menu_item_new (name, NULL);
+        g_menu_item_set_action_and_target (item,
+                                           back ? "win.back-n" : "win.forward-n",
+                                           "u", index);
+        g_menu_append_item (menu, item);
+
+        list = g_list_next (list);
+        ++index;
+    }
+}
+
+static void
+show_menu (NautilusHistoryControls *self,
+           GtkWidget               *widget)
+{
+    g_autoptr (GMenu) menu = NULL;
+    NautilusNavigationDirection direction;
+    GtkPopoverMenu *popover;
+
+    menu = g_menu_new ();
+
+    direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
+                                                     "nav-direction"));
+
+    switch (direction)
+    {
+        case NAUTILUS_NAVIGATION_DIRECTION_FORWARD:
+        {
+            fill_menu (self, menu, FALSE);
+            popover = GTK_POPOVER_MENU (self->forward_menu);
+        }
+        break;
+
+        case NAUTILUS_NAVIGATION_DIRECTION_BACK:
+        {
+            fill_menu (self, menu, TRUE);
+            popover = GTK_POPOVER_MENU (self->back_menu);
+        }
+        break;
+
+        default:
+        {
+            g_assert_not_reached ();
+        }
+        break;
+    }
+
+    gtk_popover_menu_set_menu_model (popover, G_MENU_MODEL (menu));
+    gtk_popover_popup (GTK_POPOVER (popover));
+}
+
+static void
+navigation_button_press_cb (GtkGestureClick *gesture,
+                            gint             n_press,
+                            gdouble          x,
+                            gdouble          y,
+                            gpointer         user_data)
+{
+    NautilusHistoryControls *self;
+    NautilusWindow *window;
+    GtkWidget *widget;
+    guint button;
+
+    self = NAUTILUS_HISTORY_CONTROLS (user_data);
+    button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
+    widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
+    window = NAUTILUS_WINDOW (gtk_widget_get_root (GTK_WIDGET (self)));
+
+    if (button == GDK_BUTTON_PRIMARY)
+    {
+        /* Don't do anything, primary click is handled through activate */
+        gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
+        return;
+    }
+    else if (button == GDK_BUTTON_MIDDLE)
+    {
+        NautilusNavigationDirection direction;
+
+        direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
+                                                         "nav-direction"));
+
+        nautilus_window_back_or_forward_in_new_tab (window, direction);
+    }
+    else if (button == GDK_BUTTON_SECONDARY)
+    {
+        show_menu (self, widget);
+    }
+}
+
+static void
+back_button_longpress_cb (GtkGestureLongPress *gesture,
+                          double               x,
+                          double               y,
+                          gpointer             user_data)
+{
+    NautilusHistoryControls *self = user_data;
+
+    show_menu (self, self->back_button);
+}
+
+static void
+forward_button_longpress_cb (GtkGestureLongPress *gesture,
+                             double               x,
+                             double               y,
+                             gpointer             user_data)
+{
+    NautilusHistoryControls *self = user_data;
+
+    show_menu (self, self->forward_button);
+}
+
+
+static void
+nautilus_history_controls_contructed (GObject *object)
+{
+    NautilusHistoryControls *self;
+    GtkEventController *controller;
+
+    self = NAUTILUS_HISTORY_CONTROLS (object);
+
+    controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
+    gtk_widget_add_controller (self->back_button, controller);
+    g_signal_connect (controller, "pressed",
+                      G_CALLBACK (back_button_longpress_cb), self);
+
+    controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
+    gtk_widget_add_controller (self->forward_button, controller);
+    g_signal_connect (controller, "pressed",
+                      G_CALLBACK (forward_button_longpress_cb), self);
+
+    g_object_set_data (G_OBJECT (self->back_button), "nav-direction",
+                       GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_BACK));
+    g_object_set_data (G_OBJECT (self->forward_button), "nav-direction",
+                       GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD));
+
+    controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+    gtk_widget_add_controller (self->back_button, controller);
+    gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
+    g_signal_connect (controller, "pressed",
+                      G_CALLBACK (navigation_button_press_cb), self);
+
+    controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+    gtk_widget_add_controller (self->forward_button, controller);
+    gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
+    g_signal_connect (controller, "pressed",
+                      G_CALLBACK (navigation_button_press_cb), self);
+}
+
+static void
+nautilus_history_controls_dispose (GObject *object)
+{
+    NautilusHistoryControls *self;
+
+    self = NAUTILUS_HISTORY_CONTROLS (object);
+
+    g_clear_pointer (&self->back_menu, gtk_widget_unparent);
+    g_clear_pointer (&self->forward_menu, gtk_widget_unparent);
+
+    G_OBJECT_CLASS (nautilus_history_controls_parent_class)->dispose (object);
+}
+
+static void
+nautilus_history_controls_set_window_slot (NautilusHistoryControls *self,
+                                           NautilusWindowSlot      *window_slot)
+{
+    g_return_if_fail (NAUTILUS_IS_HISTORY_CONTROLS (self));
+    g_return_if_fail (window_slot == NULL || NAUTILUS_IS_WINDOW_SLOT (window_slot));
+
+    if (self->window_slot == window_slot)
+    {
+        return;
+    }
+
+    self->window_slot = window_slot;
+
+    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WINDOW_SLOT]);
+}
+
+static void
+nautilus_history_controls_get_property (GObject    *object,
+                                        guint       prop_id,
+                                        GValue     *value,
+                                        GParamSpec *pspec)
+{
+    NautilusHistoryControls *self = NAUTILUS_HISTORY_CONTROLS (object);
+
+    switch (prop_id)
+    {
+        case PROP_WINDOW_SLOT:
+        {
+            g_value_set_object (value, G_OBJECT (self->window_slot));
+            break;
+        }
+
+        default:
+        {
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        }
+    }
+}
+
+static void
+nautilus_history_controls_set_property (GObject      *object,
+                                        guint         prop_id,
+                                        const GValue *value,
+                                        GParamSpec   *pspec)
+{
+    NautilusHistoryControls *self = NAUTILUS_HISTORY_CONTROLS (object);
+
+    switch (prop_id)
+    {
+        case PROP_WINDOW_SLOT:
+        {
+            nautilus_history_controls_set_window_slot (self, NAUTILUS_WINDOW_SLOT (g_value_get_object 
(value)));
+            break;
+        }
+
+        default:
+        {
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        }
+    }
+}
+
+static void
+nautilus_history_controls_class_init (NautilusHistoryControlsClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+    object_class->constructed = nautilus_history_controls_contructed;
+    object_class->dispose = nautilus_history_controls_dispose;
+    object_class->set_property = nautilus_history_controls_set_property;
+    object_class->get_property = nautilus_history_controls_get_property;
+
+    properties[PROP_WINDOW_SLOT] = g_param_spec_object ("window-slot",
+                                                        NULL, NULL,
+                                                        NAUTILUS_TYPE_WINDOW_SLOT,
+                                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | 
G_PARAM_EXPLICIT_NOTIFY);
+
+    g_object_class_install_properties (object_class, N_PROPS, properties);
+
+    gtk_widget_class_set_template_from_resource (widget_class,
+                                                 "/org/gnome/nautilus/ui/nautilus-history-controls.ui");
+    gtk_widget_class_bind_template_child (widget_class, NautilusHistoryControls, back_button);
+    gtk_widget_class_bind_template_child (widget_class, NautilusHistoryControls, back_menu);
+    gtk_widget_class_bind_template_child (widget_class, NautilusHistoryControls, forward_button);
+    gtk_widget_class_bind_template_child (widget_class, NautilusHistoryControls, forward_menu);
+}
+
+static void
+nautilus_history_controls_init (NautilusHistoryControls *self)
+{
+    gtk_widget_init_template (GTK_WIDGET (self));
+
+    gtk_widget_set_parent (self->back_menu, self->back_button);
+    g_signal_connect (self->back_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL);
+    gtk_widget_set_parent (self->forward_menu, self->forward_button);
+    g_signal_connect (self->forward_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL);
+}
diff --git a/src/nautilus-history-controls.h b/src/nautilus-history-controls.h
new file mode 100644
index 000000000..26d484d53
--- /dev/null
+++ b/src/nautilus-history-controls.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+#include <libadwaita-1/adwaita.h>
+
+#include "nautilus-window-slot.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_HISTORY_CONTROLS nautilus_history_controls_get_type()
+
+G_DECLARE_FINAL_TYPE (NautilusHistoryControls, nautilus_history_controls, NAUTILUS, HISTORY_CONTROLS, AdwBin)
+
+G_END_DECLS
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 27a5f6402..41ef83ade 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -30,6 +30,7 @@
 #include "nautilus-file-operations.h"
 #include "nautilus-file-undo-manager.h"
 #include "nautilus-global-preferences.h"
+#include "nautilus-history-controls.h"
 #include "nautilus-location-entry.h"
 #include "nautilus-pathbar.h"
 #include "nautilus-progress-info-manager.h"
@@ -81,12 +82,6 @@ struct _NautilusToolbar
     gboolean show_sidebar_button;
     gboolean sidebar_button_active;
 
-    GtkWidget *forward_button;
-    GtkWidget *forward_menu;
-
-    GtkWidget *back_button;
-    GtkWidget *back_menu;
-
     GtkWidget *search_button;
 
     GtkWidget *location_entry_close_button;
@@ -141,133 +136,6 @@ toolbar_update_appearance (NautilusToolbar *self)
     }
 }
 
-static void
-fill_menu (NautilusToolbar *self,
-           GMenu           *menu,
-           gboolean         back)
-{
-    guint index;
-    GList *list;
-    const gchar *name;
-
-    list = back ? nautilus_window_slot_get_back_history (self->window_slot) :
-           nautilus_window_slot_get_forward_history (self->window_slot);
-
-    index = 0;
-    while (list != NULL)
-    {
-        g_autoptr (GMenuItem) item = NULL;
-
-        name = nautilus_bookmark_get_name (NAUTILUS_BOOKMARK (list->data));
-        item = g_menu_item_new (name, NULL);
-        g_menu_item_set_action_and_target (item,
-                                           back ? "win.back-n" : "win.forward-n",
-                                           "u", index);
-        g_menu_append_item (menu, item);
-
-        list = g_list_next (list);
-        ++index;
-    }
-}
-
-static void
-show_menu (NautilusToolbar *self,
-           GtkWidget       *widget)
-{
-    g_autoptr (GMenu) menu = NULL;
-    NautilusNavigationDirection direction;
-    GtkPopoverMenu *popover;
-
-    menu = g_menu_new ();
-
-    direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
-                                                     "nav-direction"));
-
-    switch (direction)
-    {
-        case NAUTILUS_NAVIGATION_DIRECTION_FORWARD:
-        {
-            fill_menu (self, menu, FALSE);
-            popover = GTK_POPOVER_MENU (self->forward_menu);
-        }
-        break;
-
-        case NAUTILUS_NAVIGATION_DIRECTION_BACK:
-        {
-            fill_menu (self, menu, TRUE);
-            popover = GTK_POPOVER_MENU (self->back_menu);
-        }
-        break;
-
-        default:
-        {
-            g_assert_not_reached ();
-        }
-        break;
-    }
-
-    gtk_popover_menu_set_menu_model (popover, G_MENU_MODEL (menu));
-    gtk_popover_popup (GTK_POPOVER (popover));
-}
-
-static void
-navigation_button_press_cb (GtkGestureClick *gesture,
-                            gint             n_press,
-                            gdouble          x,
-                            gdouble          y,
-                            gpointer         user_data)
-{
-    NautilusToolbar *self;
-    GtkWidget *widget;
-    guint button;
-
-    self = NAUTILUS_TOOLBAR (user_data);
-    button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
-    widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
-
-    if (button == GDK_BUTTON_PRIMARY)
-    {
-        /* Don't do anything, primary click is handled through activate */
-        gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
-        return;
-    }
-    else if (button == GDK_BUTTON_MIDDLE)
-    {
-        NautilusNavigationDirection direction;
-
-        direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
-                                                         "nav-direction"));
-
-        nautilus_window_back_or_forward_in_new_tab (self->window, direction);
-    }
-    else if (button == GDK_BUTTON_SECONDARY)
-    {
-        show_menu (self, widget);
-    }
-}
-
-static void
-back_button_longpress_cb (GtkGestureLongPress *gesture,
-                          double               x,
-                          double               y,
-                          gpointer             user_data)
-{
-    NautilusToolbar *self = user_data;
-
-    show_menu (self, self->back_button);
-}
-
-static void
-forward_button_longpress_cb (GtkGestureLongPress *gesture,
-                             double               x,
-                             double               y,
-                             gpointer             user_data)
-{
-    NautilusToolbar *self = user_data;
-
-    show_menu (self, self->forward_button);
-}
-
 static gboolean
 should_show_progress_info (NautilusProgressInfo *info)
 {
@@ -808,7 +676,6 @@ static void
 nautilus_toolbar_constructed (GObject *object)
 {
     NautilusToolbar *self = NAUTILUS_TOOLBAR (object);
-    GtkEventController *controller;
 
     self->path_bar = GTK_WIDGET (g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL));
     gtk_box_append (GTK_BOX (self->path_bar_container),
@@ -837,33 +704,6 @@ nautilus_toolbar_constructed (GObject *object)
                              NULL);
     update_operations (self);
 
-    controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
-    gtk_widget_add_controller (self->back_button, controller);
-    g_signal_connect (controller, "pressed",
-                      G_CALLBACK (back_button_longpress_cb), self);
-
-    controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
-    gtk_widget_add_controller (self->forward_button, controller);
-    g_signal_connect (controller, "pressed",
-                      G_CALLBACK (forward_button_longpress_cb), self);
-
-    g_object_set_data (G_OBJECT (self->back_button), "nav-direction",
-                       GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_BACK));
-    g_object_set_data (G_OBJECT (self->forward_button), "nav-direction",
-                       GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD));
-
-    controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
-    gtk_widget_add_controller (self->back_button, controller);
-    gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
-    g_signal_connect (controller, "pressed",
-                      G_CALLBACK (navigation_button_press_cb), self);
-
-    controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
-    gtk_widget_add_controller (self->forward_button, controller);
-    gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
-    g_signal_connect (controller, "pressed",
-                      G_CALLBACK (navigation_button_press_cb), self);
-
     g_signal_connect (self->operations_popover, "show",
                       (GCallback) gtk_widget_grab_focus, NULL);
     g_signal_connect_swapped (self->operations_popover, "closed",
@@ -882,17 +722,14 @@ nautilus_toolbar_constructed (GObject *object)
 static void
 nautilus_toolbar_init (NautilusToolbar *self)
 {
+    g_type_ensure (NAUTILUS_TYPE_HISTORY_CONTROLS);
+
     gtk_widget_init_template (GTK_WIDGET (self));
 
     gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->operations_icon),
                                     (GtkDrawingAreaDrawFunc) on_operations_icon_draw,
                                     self,
                                     NULL);
-
-    gtk_widget_set_parent (self->back_menu, self->back_button);
-    g_signal_connect (self->back_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL);
-    gtk_widget_set_parent (self->forward_menu, self->forward_button);
-    g_signal_connect (self->forward_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL);
 }
 
 void
@@ -1083,8 +920,6 @@ nautilus_toolbar_dispose (GObject *object)
     self = NAUTILUS_TOOLBAR (object);
 
     g_clear_pointer (&self->search_binding, g_binding_unbind);
-    g_clear_pointer (&self->back_menu, gtk_widget_unparent);
-    g_clear_pointer (&self->forward_menu, gtk_widget_unparent);
 
     G_OBJECT_CLASS (nautilus_toolbar_parent_class)->dispose (object);
 }
@@ -1183,10 +1018,6 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_split_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, app_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, undo_redo_section);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, back_button);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, back_menu);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, forward_button);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, forward_menu);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, toolbar_switcher);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_container);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, path_bar_container);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index cf54b6f52..b202597d3 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -6,6 +6,7 @@
     <file>ui/nautilus-app-chooser.ui</file>
     <file>ui/nautilus-pathbar-context-menu.ui</file>
     <file>ui/nautilus-toolbar.ui</file>
+    <file>ui/nautilus-history-controls.ui</file>
     <file>ui/nautilus-toolbar-view-menu.ui</file>
     <file>ui/nautilus-column-chooser.ui</file>
     <file>ui/nautilus-list-view-column-editor.ui</file>
diff --git a/src/resources/ui/nautilus-history-controls.ui b/src/resources/ui/nautilus-history-controls.ui
new file mode 100644
index 000000000..b16ec45e8
--- /dev/null
+++ b/src/resources/ui/nautilus-history-controls.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkPopoverMenu" id="back_menu"/>
+  <object class="GtkPopoverMenu" id="forward_menu"/>
+  <template class="NautilusHistoryControls" parent="AdwBin">
+    <property name="child">
+      <object class="GtkBox">
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkButton" id="back_button">
+            <property name="tooltip_text" translatable="yes">Go back</property>
+            <property name="valign">center</property>
+            <property name="action_name">win.back</property>
+            <property name="icon_name">go-previous-symbolic</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton" id="forward_button">
+            <property name="tooltip_text" translatable="yes">Go forward</property>
+            <property name="valign">center</property>
+            <property name="action_name">win.forward</property>
+            <property name="icon_name">go-next-symbolic</property>
+          </object>
+        </child>
+      </object>
+    </property>
+  </template>
+</interface>
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index 682fff316..083aeeb6b 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -1,8 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk" version="4.0"/>
-  <object class="GtkPopoverMenu" id="back_menu"/>
-  <object class="GtkPopoverMenu" id="forward_menu"/>
   <menu id="view_menu">
     <section>
       <attribute name="label" translatable="yes" context="menu item" comments="Translators: a menu item in a 
group of sorting options in a toolbar menu, with criterions such as &quot;A-Z&quot; or &quot;Last 
Modified&quot;.">Sort</attribute>
@@ -169,28 +167,20 @@
           </object>
         </child>
         <child type="start">
-          <object class="GtkButton" id="back_button">
-            <property name="tooltip_text" translatable="yes">Go back</property>
-            <property name="halign">center</property>
-            <property name="valign">center</property>
-            <property name="action_name">win.back</property>
-            <property name="icon_name">go-previous-symbolic</property>
-          </object>
-        </child>
-        <child type="start">
-          <object class="GtkButton" id="forward_button">
-            <property name="tooltip_text" translatable="yes">Go forward</property>
-            <property name="halign">center</property>
-            <property name="valign">center</property>
-            <property name="action_name">win.forward</property>
-            <property name="icon_name">go-next-symbolic</property>
-          </object>
-        </child>
-        <child type="start">
-          <object class="GtkSeparator">
-            <style>
-              <class name="spacer"/>
-            </style>
+          <object class="GtkBox">
+            <property name="spacing">6</property>
+            <child>
+              <object class="NautilusHistoryControls">
+                <property name="window-slot" bind-source="NautilusToolbar" bind-property="window-slot" 
bind-flags="sync-create"/>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSeparator">
+                <style>
+                  <class name="spacer"/>
+                </style>
+              </object>
+            </child>
           </object>
         </child>
         <child type="end">


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