[nautilus/wip/cdavis/adaptive-flap: 174/178] Add NautilusBottomToolbar




commit 550fa97965d1907378a3e88655147ef537346249
Author: Christopher Davis <brainblasted disroot org>
Date:   Tue Dec 8 08:21:52 2020 -0800

    Add NautilusBottomToolbar
    
    Adds a basic bottom toolbar to the main window.
    
    TODO:
    
    * Sync view buttons
    * Fix popover bugs
    * Add operations popover to the bottom bar

 src/meson.build                             |   2 +
 src/nautilus-bottom-toolbar.c               |  53 ++++++
 src/nautilus-bottom-toolbar.h               |  35 ++++
 src/nautilus-navigation-direction.h         |  34 ++++
 src/nautilus-toolbar.c                      |   8 +-
 src/nautilus-window.c                       |  13 ++
 src/resources/nautilus.gresource.xml        |   1 +
 src/resources/ui/nautilus-bottom-toolbar.ui | 257 ++++++++++++++++++++++++++++
 src/resources/ui/nautilus-window.ui         |  17 +-
 9 files changed, 410 insertions(+), 10 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 0672359a5..5cbf787fe 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -69,6 +69,8 @@ libnautilus_sources = [
   'nautilus-application.h',
   'nautilus-bookmark-list.c',
   'nautilus-bookmark-list.h',
+  'nautilus-bottom-toolbar.c',
+  'nautilus-bottom-toolbar.h',
   'nautilus-canvas-view.c',
   'nautilus-canvas-view.h',
   'nautilus-canvas-view-container.c',
diff --git a/src/nautilus-bottom-toolbar.c b/src/nautilus-bottom-toolbar.c
new file mode 100644
index 000000000..2a1fca1a6
--- /dev/null
+++ b/src/nautilus-bottom-toolbar.c
@@ -0,0 +1,53 @@
+/* nautilus-bottom-toolbar.c
+ *
+ * Copyright 2020 Christopher Davis <christopherdavis gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "nautilus-bottom-toolbar.h"
+
+#include <math.h>
+
+#include "nautilus-navigation-direction.h"
+#include "nautilus-window.h"
+
+struct _NautilusBottomToolbar
+{
+    GtkRevealer parent_instance;
+
+    NautilusWindow *window;
+};
+
+G_DEFINE_TYPE (NautilusBottomToolbar, nautilus_bottom_toolbar, GTK_TYPE_REVEALER);
+
+static void
+nautilus_bottom_toolbar_class_init (NautilusBottomToolbarClass *klass)
+{
+    // GObjectClass *oclass;
+    GtkWidgetClass *widget_class;
+
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gtk_widget_class_set_template_from_resource (widget_class,
+                                                 "/org/gnome/nautilus/ui/nautilus-bottom-toolbar.ui");
+}
+
+static void
+nautilus_bottom_toolbar_init (NautilusBottomToolbar *self)
+{
+    gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/nautilus-bottom-toolbar.h b/src/nautilus-bottom-toolbar.h
new file mode 100644
index 000000000..aaaacca6e
--- /dev/null
+++ b/src/nautilus-bottom-toolbar.h
@@ -0,0 +1,35 @@
+/* nautilus-bottom-toolbar.h
+ *
+ * Copyright 2020 Christopher Davis <christopherdavis gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_BOTTOM_TOOLBAR nautilus_bottom_toolbar_get_type()
+
+G_DECLARE_FINAL_TYPE (NautilusBottomToolbar, nautilus_bottom_toolbar, NAUTILUS, BOTTOM_TOOLBAR, GtkRevealer)
+
+GtkWidget *nautilus_bottom_toolbar_new                         (void);
+gboolean   nautilus_bottom_toolbar_is_operations_button_active (NautilusBottomToolbar *toolbar);
+void      *nautilus_bottom_toolbar_on_window_contructed        (NautilusBottomToolbar *toolbar);
+
+G_END_DECLS
diff --git a/src/nautilus-navigation-direction.h b/src/nautilus-navigation-direction.h
new file mode 100644
index 000000000..18200cfff
--- /dev/null
+++ b/src/nautilus-navigation-direction.h
@@ -0,0 +1,34 @@
+/* nautilus-navigation-direction.h
+ *
+ * Copyright 2020 Christopher Davis <christopherdavis gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+    NAUTILUS_NAVIGATION_DIRECTION_NONE,
+    NAUTILUS_NAVIGATION_DIRECTION_BACK,
+    NAUTILUS_NAVIGATION_DIRECTION_FORWARD
+} NautilusNavigationDirection;
+
+G_END_DECLS
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 3f0b1eec8..5753946e0 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -34,6 +34,7 @@
 #include "nautilus-file-undo-manager.h"
 #include "nautilus-global-preferences.h"
 #include "nautilus-location-entry.h"
+#include "nautilus-navigation-direction.h"
 #include "nautilus-pathbar.h"
 #include "nautilus-progress-info-manager.h"
 #include "nautilus-progress-info-widget.h"
@@ -52,13 +53,6 @@
 /* Just design, context at https://gitlab.gnome.org/GNOME/nautilus/issues/548#note_274131 */
 #define SWITCHER_MAX_WIDTH 840
 
-typedef enum
-{
-    NAUTILUS_NAVIGATION_DIRECTION_NONE,
-    NAUTILUS_NAVIGATION_DIRECTION_BACK,
-    NAUTILUS_NAVIGATION_DIRECTION_FORWARD
-} NautilusNavigationDirection;
-
 struct _NautilusToolbar
 {
     GtkHeaderBar parent_instance;
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index b0cc14443..d24209136 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -50,6 +50,7 @@
 #include "nautilus-adaptive-mode.h"
 #include "nautilus-application.h"
 #include "nautilus-bookmark-list.h"
+#include "nautilus-bottom-toolbar.h"
 #include "nautilus-clipboard.h"
 #include "nautilus-dnd.h"
 #include "nautilus-enums.h"
@@ -135,6 +136,7 @@ struct _NautilusWindow
 
     /* Toolbar */
     GtkWidget *toolbar;
+    GtkWidget *bottom_toolbar;
     gboolean temporary_navigation_bar;
 
     /* focus widget before the location bar has been shown temporarily */
@@ -730,6 +732,15 @@ update_adaptive_mode (NautilusWindow *window)
                     NAUTILUS_ADAPTIVE_MODE_NARROW :
                     NAUTILUS_ADAPTIVE_MODE_NORMAL;
     nautilus_toolbar_set_adaptive_mode (toolbar, adaptive_mode);
+
+    if (adaptive_mode == NAUTILUS_ADAPTIVE_MODE_NARROW)
+    {
+        gtk_revealer_set_reveal_child (GTK_REVEALER (window->bottom_toolbar), TRUE);
+    }
+    else
+    {
+        gtk_revealer_set_reveal_child (GTK_REVEALER (window->bottom_toolbar), FALSE);
+    }
 }
 
 static void
@@ -2726,6 +2737,7 @@ nautilus_window_init (NautilusWindow *window)
 
     g_type_ensure (NAUTILUS_TYPE_TOOLBAR);
     g_type_ensure (NAUTILUS_TYPE_NOTEBOOK);
+    g_type_ensure (NAUTILUS_TYPE_BOTTOM_TOOLBAR);
     gtk_widget_init_template (GTK_WIDGET (window));
 
     g_signal_connect (window, "notify::is-maximized",
@@ -2792,6 +2804,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
     gtk_widget_class_set_template_from_resource (wclass,
                                                  "/org/gnome/nautilus/ui/nautilus-window.ui");
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, toolbar);
+    gtk_widget_class_bind_template_child (wclass, NautilusWindow, bottom_toolbar);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, content_flap);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, sidebar);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, places_sidebar);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 6265c8fff..3bae7d9cc 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -20,6 +20,7 @@
     <file>gtk/help-overlay.ui</file>
     <file>ui/nautilus-batch-rename-dialog.ui</file>
     <file>ui/nautilus-batch-rename-dialog-menu.ui</file>
+    <file>ui/nautilus-bottom-toolbar.ui</file>
     <file>ui/nautilus-properties-window.ui</file>
     <file>ui/nautilus-file-properties-change-permissions.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
diff --git a/src/resources/ui/nautilus-bottom-toolbar.ui b/src/resources/ui/nautilus-bottom-toolbar.ui
new file mode 100644
index 000000000..897968d6b
--- /dev/null
+++ b/src/resources/ui/nautilus-bottom-toolbar.ui
@@ -0,0 +1,257 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.22"/>
+  <object class="GtkPopover" id="bottom_operations_popover">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hscrollbar_policy">never</property>
+        <property name="max_content_height">270</property>
+        <property name="propagate_natural_height">True</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkBox" id="operations_container">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_start">12</property>
+                <property name="margin_end">12</property>
+                <property name="margin_top">12</property>
+                <property name="margin_bottom">12</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">10</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkPopoverMenu" id="bottom_menu_popover">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox">
+        <property name="width_request">160</property>
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">9</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkBox" id="view_menu_zoom_section">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox" id="view_menu_undo_redo_section">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_top">6</property>
+                <property name="margin_bottom">6</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="undo_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="action_name">win.undo</property>
+                <property name="text" translatable="yes">_Undo</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="redo_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="action_name">win.redo</property>
+                <property name="text" translatable="yes">_Redo</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox" id="view_menu_extended_section">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="submenu">main</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
+  <template class="NautilusBottomToolbar" parent="GtkRevealer">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkActionBar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkBox" id="navigation_box">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkButton" id="back_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <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>
+                <child>
+                  <object class="GtkImage" id="back_icon">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">go-previous-symbolic</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="forward_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <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>
+                <child>
+                  <object class="GtkImage" id="forward_icon">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">go-next-symbolic</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <style>
+              <class name="linked"/>
+              <class name="raised"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack_type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="views_box">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="halign">end</property>
+            <child>
+              <object class="GtkRevealer" id="operations_revealer">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <property name="transition_type">slide-right</property>
+                <child>
+                  <object class="GtkMenuButton" id="operations_button">
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">Show operations</property>
+                    <property name="margin_end">6</property>
+                    <property name="popover">bottom_operations_popover</property>
+                    <signal name="toggled" handler="on_operations_button_toggled" object="NautilusToolbar" 
swapped="yes"/>
+                    <child>
+                      <object class="GtkDrawingArea" id="operations_icon">
+                        <property name="width_request">16</property>
+                        <property name="height_request">16</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">center</property>
+                        <property name="valign">center</property>
+                        <signal name="draw" handler="on_operations_icon_draw" object="NautilusToolbar" 
swapped="no"/>
+                      </object>
+                    </child>
+                    <style>
+                      <class name="button"/>
+                    </style>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkBox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <child>
+                  <object class="GtkButton" id="view_toggle_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">Toggle view</property>
+                    <property name="action_name">slot.files-view-mode-toggle</property>
+                    <child>
+                      <object class="GtkImage" id="view_toggle_icon">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="icon_name">view-list-symbolic</property>
+                      </object>
+                    </child>
+                    <style>
+                      <class name="image-button"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkMenuButton" id="view_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="tooltip_text" translatable="yes" comments="“View” is a noun">View 
options</property>
+                    <property name="halign">start</property>
+                    <property name="action_name">win.view-menu</property>
+                    <property name="popover">bottom_menu_popover</property>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="icon_name">pan-down-symbolic</property>
+                      </object>
+                    </child>
+                    <style>
+                      <class name="disclosure-button"/>
+                    </style>
+                  </object>
+                </child>
+                <style>
+                  <class name="linked"/>
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+          </packing>
+        </child>
+        <style>
+          <class name="background"/>
+        </style>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index b356fdde2..1bbc1898d 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -25,6 +25,7 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <property name="width_request">240</property>
+                <property name="hexpand_set">True</property>
                 <child>
                   <object class="GtkPlacesSidebar" id="places_sidebar">
                     <property name="visible">True</property>
@@ -47,10 +48,20 @@
                 <property name="visible">True</property>
                 <property name="width_request">360</property>
                 <child>
-                  <object class="NautilusNotebook" id="notebook">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
-                    <property name="show-tabs">False</property>
-                    <property name="show-border">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <object class="NautilusNotebook" id="notebook">
+                        <property name="visible">True</property>
+                        <property name="show-tabs">False</property>
+                        <property name="show-border">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="NautilusBottomToolbar" id="bottom_toolbar"/>
+                    </child>
                   </object>
                 </child>
                 <child type="overlay">


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