[nautilus/wip/cdavis/adaptive-flap: 1/7] general: Use libhandy and HdyFlap




commit d2d2e00fcf649696a73c2faa0e7fc388edc3f440
Author: Christopher Davis <brainblasted disroot org>
Date:   Tue Nov 17 12:51:04 2020 -0800

    general: Use libhandy and HdyFlap
    
    Use libhandy + HdyFlap for an initial adaptive sidebar.

 build-aux/flatpak/org.gnome.Nautilus.json | 12 ++++++
 meson.build                               |  1 +
 src/meson.build                           |  1 +
 src/nautilus-application.c                |  3 ++
 src/nautilus-window.c                     | 66 +------------------------------
 src/resources/ui/nautilus-window.ui       | 14 +++----
 6 files changed, 24 insertions(+), 73 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Nautilus.json b/build-aux/flatpak/org.gnome.Nautilus.json
index 8956d6b68..6a2b07310 100644
--- a/build-aux/flatpak/org.gnome.Nautilus.json
+++ b/build-aux/flatpak/org.gnome.Nautilus.json
@@ -22,6 +22,7 @@
     "--filesystem=~/.config/dconf:ro",
     "--talk-name=ca.desrt.dconf",
     "--env=DCONF_USER_CONFIG_DIR=.config/dconf",
+    "--env=GTK_DEBUG=interactive",
     "--add-policy=Tracker3.dbus:org.freedesktop.Tracker3.Miner.Files=tracker:FileSystem;tracker:Documents"
   ],
   "modules": [
@@ -107,6 +108,17 @@
         }
       ]
     },
+    {
+      "name": "libhandy",
+      "buildsystem": "meson",
+      "sources": [
+        {
+          "type": "git",
+          "url": "https://gitlab.gnome.org/GNOME/libhandy.git";,
+          "branch": "wip/haecker-felix/flap-widget"
+        }
+      ]
+    },
     {
       "buildsystem": "meson",
       "builddir": true,
diff --git a/meson.build b/meson.build
index 0939a4dac..190aa6251 100644
--- a/meson.build
+++ b/meson.build
@@ -120,6 +120,7 @@ gmodule = dependency('gmodule-no-export-2.0', version: glib_ver)
 gnome_autoar = dependency('gnome-autoar-0', version: '>= 0.2.1')
 gnome_desktop = dependency('gnome-desktop-3.0', version: '>= 3.0.0')
 gtk = dependency('gtk+-3.0', version: '>= 3.22.27')
+libhandy = dependency('libhandy-1')
 selinux = []
 if get_option('selinux')
   selinux = dependency('libselinux', version: '>= 2.0')
diff --git a/src/meson.build b/src/meson.build
index 51cdb06f8..cbc9ab15e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -283,6 +283,7 @@ nautilus_deps = [
   gnome_autoar,
   gnome_desktop,
   libgd_dep,
+  libhandy,
   nautilus_extension,
   selinux,
   tracker_sparql,
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 10478da9c..572adbcfa 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -34,6 +34,7 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
+#include <libhandy-1/handy.h>
 #include <nautilus-extension.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -1326,6 +1327,8 @@ nautilus_application_startup_common (NautilusApplication *self)
      */
     G_APPLICATION_CLASS (nautilus_application_parent_class)->startup (G_APPLICATION (self));
 
+    hdy_init ();
+
     gtk_window_set_default_icon_name (APPLICATION_ID);
 
     setup_theme_extensions ();
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index c81d150d1..5b90bc186 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -108,10 +108,9 @@ struct _NautilusWindow
     GList *slots;
     NautilusWindowSlot *active_slot;
 
-    GtkWidget *content_paned;
+    GtkWidget *content_flap;
 
     /* Side Pane */
-    int side_pane_width;
     GtkWidget *sidebar;            /* container for the GtkPlacesSidebar */
     GtkWidget *places_sidebar;     /* the actual GtkPlacesSidebar */
     GVolume *selected_volume;     /* the selected volume in the sidebar popup callback */
@@ -882,60 +881,6 @@ nautilus_window_get_notebook (NautilusWindow *window)
     return window->notebook;
 }
 
-static gboolean
-save_sidebar_width_cb (gpointer user_data)
-{
-    NautilusWindow *window = user_data;
-
-
-    window->sidebar_width_handler_id = 0;
-
-    DEBUG ("Saving sidebar width: %d", window->side_pane_width);
-
-    g_settings_set_int (nautilus_window_state,
-                        NAUTILUS_WINDOW_STATE_SIDEBAR_WIDTH,
-                        window->side_pane_width);
-
-    return FALSE;
-}
-
-/* side pane helpers */
-static void
-side_pane_size_allocate_callback (GtkWidget     *widget,
-                                  GtkAllocation *allocation,
-                                  gpointer       user_data)
-{
-    NautilusWindow *window = user_data;
-
-
-    if (window->sidebar_width_handler_id != 0)
-    {
-        g_source_remove (window->sidebar_width_handler_id);
-        window->sidebar_width_handler_id = 0;
-    }
-
-    if (allocation->width != window->side_pane_width &&
-        allocation->width > 1)
-    {
-        window->side_pane_width = allocation->width;
-
-        window->sidebar_width_handler_id =
-            g_idle_add (save_sidebar_width_cb, window);
-    }
-}
-
-static void
-setup_side_pane_width (NautilusWindow *window)
-{
-    g_return_if_fail (window->sidebar != NULL);
-
-    window->side_pane_width =
-        g_settings_get_int (nautilus_window_state,
-                            NAUTILUS_WINDOW_STATE_SIDEBAR_WIDTH);
-
-    gtk_paned_set_position (GTK_PANED (window->content_paned),
-                            window->side_pane_width);
-}
 
 /* Callback used when the places sidebar changes location; we need to change the displayed folder */
 static void
@@ -1379,12 +1324,6 @@ places_sidebar_populate_popup_cb (GtkPlacesSidebar *sidebar,
 static void
 nautilus_window_set_up_sidebar (NautilusWindow *window)
 {
-    setup_side_pane_width (window);
-    g_signal_connect (window->sidebar,
-                      "size-allocate",
-                      G_CALLBACK (side_pane_size_allocate_callback),
-                      window);
-
     gtk_places_sidebar_set_open_flags (GTK_PLACES_SIDEBAR (window->places_sidebar),
                                        (GTK_PLACES_OPEN_NORMAL
                                         | GTK_PLACES_OPEN_NEW_TAB
@@ -1424,7 +1363,6 @@ nautilus_window_show_sidebar (NautilusWindow *window)
     g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
     gtk_widget_show (window->sidebar);
-    setup_side_pane_width (window);
 }
 
 static inline NautilusWindowSlot *
@@ -2839,7 +2777,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, content_paned);
+    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);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, main_view);
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index 4eef37c11..25c797001 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
+  <!-- TODO: Use child type="flap" when added to libhandy -->
   <template class="NautilusWindow" parent="GtkApplicationWindow">
     <property name="show-menubar">False</property>
     <property name="title" translatable="yes">_Files</property>
@@ -7,15 +8,16 @@
       <object class="GtkGrid">
         <property name="visible">True</property>
         <child>
-          <object class="GtkPaned" id="content_paned">
+          <object class="HdyFlap" id="content_flap">
             <property name="visible">True</property>
             <property name="vexpand">True</property>
             <property name="hexpand">True</property>
-            <child>
+            <child type="flap">
               <object class="GtkBox" id="sidebar">
                 <property name="visible">False</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
+                <property name="width_request">204</property>
                 <child>
                   <object class="GtkPlacesSidebar" id="places_sidebar">
                     <property name="visible">True</property>
@@ -32,14 +34,11 @@
                   </packing>
                 </child>
               </object>
-              <packing>
-               <property name="resize">False</property>
-               <property name="shrink">False</property>
-              </packing>
             </child>
             <child>
               <object class="GtkOverlay" id="main_view">
                 <property name="visible">True</property>
+                <property name="width_request">360</property>
                 <child>
                   <object class="NautilusNotebook" id="notebook">
                     <property name="visible">True</property>
@@ -185,9 +184,6 @@
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="shrink">False</property>
-              </packing>
             </child>
           </object>
         </child>


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