[nautilus/wip/cdavis/adaptive-flap: 3/7] window: Bind flap and fold button




commit 622ddb5feb2068d6a6d3b95e30dbc30d7f1f4133
Author: Christopher Davis <brainblasted disroot org>
Date:   Tue Nov 17 16:10:39 2020 -0800

    window: Bind flap and fold button
    
    Ties the HdyFlap to a fold button via GBinding. This allows
    users to toggle the flap at small sizes.

 icons/show-sidebar-symbolic.svg      | 67 ++++++++++++++++++++++++++++++++++++
 src/nautilus-toolbar.c               | 49 ++++++++++++++++++++++++++
 src/resources/nautilus.gresource.xml |  1 +
 src/resources/ui/nautilus-toolbar.ui | 11 ++++++
 src/resources/ui/nautilus-window.ui  |  7 ++--
 5 files changed, 133 insertions(+), 2 deletions(-)
---
diff --git a/icons/show-sidebar-symbolic.svg b/icons/show-sidebar-symbolic.svg
new file mode 100644
index 000000000..8374e3ef6
--- /dev/null
+++ b/icons/show-sidebar-symbolic.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16px"
+   height="16px"
+   viewBox="0 0 16 16"
+   version="1.1"
+   id="svg2419"
+   sodipodi:docname="show-sidebar-symbolic.svg"
+   inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
+  <metadata
+     id="metadata2425">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs2423" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="2560"
+     inkscape:window-height="1376"
+     id="namedview2421"
+     showgrid="false"
+     inkscape:zoom="43.663844"
+     inkscape:cx="14.840146"
+     inkscape:cy="10.795086"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg2419" />
+  <g
+     transform="matrix(3.7795275,0,0,3.7795275,3552.5713,-600.94814)"
+     id="g5090">
+    <path
+       inkscape:connector-curvature="0"
+       
style="color:#bebebe;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#2e3436;fill-opacity:1;stroke:none;stroke-width:0.264583;marker:none"
+       d="m -939.15742,159.53003 c -0.28858,0 -0.52917,0.24059 -0.52917,0.52917 v 2.11666 0.52917 h 3.70417 
v -0.52917 -2.11666 c 0,-0.28858 -0.24059,-0.52917 -0.52917,-0.52917 z m 0,0.52917 h 0.79375 v 2.11666 h 
-0.79375 z m 1.05833,0 h 1.5875 v 2.11666 h -1.5875 z"
+       id="rect10509" />
+    <rect
+       transform="matrix(0,-1,-1,0,0,0)"
+       
style="color:#bebebe;display:inline;overflow:visible;visibility:visible;opacity:0.35;fill:#2e3436;fill-opacity:1;stroke:none;stroke-width:0.264583;marker:none"
+       id="rect10511"
+       width="2.1166327"
+       height="0.79374611"
+       x="-162.17584"
+       y="938.36365" />
+  </g>
+</svg>
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index eb8605406..d86727b09 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -73,8 +73,11 @@ struct _NautilusToolbar
     NautilusContainerMaxWidth *toolbar_switcher_container_max_width;
     GtkWidget *path_bar;
     GtkWidget *location_entry;
+    GtkWidget *fold_button;
 
     gboolean show_location_entry;
+    gboolean show_fold_button;
+    gboolean fold_button_active;
     gboolean location_entry_should_auto_hide;
 
     guint start_operations_timeout_id;
@@ -121,6 +124,8 @@ enum
 {
     PROP_WINDOW = 1,
     PROP_SHOW_LOCATION_ENTRY,
+    PROP_SHOW_FOLD_BUTTON,
+    PROP_FOLD_BUTTON_ACTIVE,
     PROP_WINDOW_SLOT,
     PROP_SEARCHING,
     NUM_PROPERTIES
@@ -966,6 +971,13 @@ nautilus_toolbar_constructed (GObject *object)
     g_signal_connect (self->location_entry, "notify::has-focus",
                       G_CALLBACK (on_location_entry_focus_changed), self);
 
+    g_object_bind_property (self, "show-fold-button",
+                            self->fold_button, "visible",
+                            G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+    g_object_bind_property (self, "fold-button-active",
+                            self->fold_button, "active",
+                            G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
     gtk_widget_show_all (GTK_WIDGET (self));
     toolbar_update_appearance (self);
 }
@@ -1007,6 +1019,18 @@ nautilus_toolbar_get_property (GObject    *object,
         }
         break;
 
+        case PROP_SHOW_FOLD_BUTTON:
+        {
+            g_value_set_boolean (value, self->show_fold_button);
+        }
+        break;
+
+        case PROP_FOLD_BUTTON_ACTIVE:
+        {
+            g_value_set_boolean (value, self->fold_button_active);
+        }
+        break;
+
         case PROP_SEARCHING:
         {
             g_value_set_boolean (value, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(self->search_button)));
@@ -1106,6 +1130,18 @@ nautilus_toolbar_set_property (GObject      *object,
         }
         break;
 
+        case PROP_SHOW_FOLD_BUTTON:
+        {
+            self->show_fold_button = g_value_get_boolean (value);
+        }
+        break;
+
+        case PROP_FOLD_BUTTON_ACTIVE:
+        {
+            self->fold_button_active = g_value_get_boolean (value);
+        }
+        break;
+
         case PROP_WINDOW_SLOT:
         {
             nautilus_toolbar_set_window_slot (self, g_value_get_object (value));
@@ -1201,6 +1237,18 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
                               "Whether to show the location entry instead of the pathbar",
                               FALSE,
                               G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+    properties[PROP_SHOW_FOLD_BUTTON] =
+        g_param_spec_boolean ("show-fold-button",
+                              "Whether to show the fold button",
+                              "Whether to show the fold button for the sidebar",
+                              FALSE,
+                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+    properties[PROP_FOLD_BUTTON_ACTIVE] =
+        g_param_spec_boolean ("fold-button-active",
+                              "Whether or not the fold button is toggled",
+                              "Whether or not the fold button is toggled for the sidebar",
+                              FALSE,
+                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
     properties [PROP_WINDOW_SLOT] =
         g_param_spec_object ("window-slot",
@@ -1222,6 +1270,7 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
     gtk_widget_class_set_template_from_resource (widget_class,
                                                  "/org/gnome/nautilus/ui/nautilus-toolbar.ui");
 
+    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, fold_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_icon);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_popover);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 158594e8d..6265c8fff 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -24,6 +24,7 @@
     <file>ui/nautilus-file-properties-change-permissions.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
+    <file alias="icons/show-sidebar-symbolic.svg">../../icons/show-sidebar-symbolic.svg</file>
     <file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file>
     <file alias="icons/filmholes.png">../../icons/filmholes.png</file>
     <file>css/Adwaita.css</file>
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index 51a882838..9d1b946ba 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -534,6 +534,17 @@
         <property name="pack_type">end</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkToggleButton" id="fold_button">
+        <property name="no_show_all">True</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon_name">show-sidebar-symbolic</property>
+          </object>
+        </child>
+      </object>
+    </child>
     <child>
       <object class="GtkBox" id="navigation_box">
         <property name="visible">True</property>
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index 2e7bf14b7..98f359037 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -5,7 +5,10 @@
     <property name="show-menubar">False</property>
     <property name="title" translatable="yes">_Files</property>
     <child type="titlebar">
-      <object class="NautilusToolbar" id="toolbar"/>
+      <object class="NautilusToolbar" id="toolbar">
+        <property name="show_fold_button" bind-source="content_flap" bind-property="folded" 
bind-flags="sync-create"/>
+        <property name="fold_button_active" bind-source="content_flap" bind-property="reveal_flap" 
bind-flags="sync-create|bidirectional"/>
+      </object>
     </child>
     <child>
       <object class="GtkGrid">
@@ -20,7 +23,7 @@
                 <property name="visible">False</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
-                <property name="width_request">204</property>
+                <property name="width_request">240</property>
                 <child>
                   <object class="GtkPlacesSidebar" id="places_sidebar">
                     <property name="visible">True</property>


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