[baobab/wip/vala: 53/53] Start implementing new design



commit 77f856a52edd3921f1415770a666c326d4ecb852
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Apr 5 22:28:00 2012 +0200

    Start implementing new design
    
    Introduce two 'views' in the main window: 'All locations' and 'Result'.
    Then move the content of volume chooser dialog to the 'All locations'
    view, along with some toolbar buttons. Also, rework the toolbar for the
    'Result' view to make it more similar to other GNOME apps.

 src/baobab-application.vala |    3 +-
 src/baobab-main-window.ui   |  532 ++++++++++++++++++++++---------------------
 src/baobab-menu.ui          |   20 +-
 src/baobab-window.vala      |  105 +++++++--
 4 files changed, 364 insertions(+), 296 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index b8981d1..3d1451f 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -11,8 +11,7 @@ namespace Baobab {
 		Settings ui_settings;
 
 		protected override void activate () {
-			var window = new Window (this);
-			window.show_filesystem_usage ();
+			new Window (this);
 		}
 
 		protected override void open (File[] files, string hint) {
diff --git a/src/baobab-main-window.ui b/src/baobab-main-window.ui
index 8999ab4..62a0242 100644
--- a/src/baobab-main-window.ui
+++ b/src/baobab-main-window.ui
@@ -3,91 +3,69 @@
   <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkGrid" id="window-contents">
     <property name="visible">True</property>
-    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
     <child>
       <object class="GtkToolbar" id="toolbar">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="show_arrow">False</property>
-        <style>
-          <class name="primary-toolbar"/>
-        </style>
         <child>
-          <object class="GtkToolButton" id="scan-home-button">
-            <property name="use_action_appearance">False</property>
+          <object class="GtkToolItem" id="home-page-toolitem">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup" translatable="yes">Scan your home folder</property>
-            <property name="tooltip_text" translatable="yes">Scan your home folder</property>
-            <property name="use_action_appearance">False</property>
-            <property name="is_important">True</property>
-            <property name="action_name">win.scan-home</property>
-            <property name="label" translatable="yes">Scan Home</property>
-            <property name="use_underline">True</property>
-            <property name="stock_id">gtk-home</property>
-            <child internal-child="accessible">
-              <object class="AtkObject" id="scan-home-button-atkobject">
-                <property name="AtkObject::accessible-name" translatable="yes">Scan your home folder</property>
+            <child>
+              <object class="GtkButtonBox" id="scan-buttonbox">
+                <property name="visible">True</property>
+                <property name="layout_style">start</property>
+                <style>
+                  <class name="linked"/>
+                </style>
+                <child>
+                  <object class="GtkButton" id="scan-folder-button">
+                    <property name="use_action_appearance">False</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup" translatable="yes">Scan a folder</property>
+                    <property name="tooltip_text" translatable="yes">Scan a folder</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="action_name">win.scan-folder</property>
+                    <property name="label" translatable="yes">Scan Folder</property>
+                    <property name="use_underline">True</property>
+                    <!--<property name="stock_id">gtk-directory</property>-->
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkButton" id="scan-remote-button">
+                    <property name="use_action_appearance">False</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup" translatable="yes">Scan a remote folder</property>
+                    <property name="tooltip_text" translatable="yes">Scan a remote folder</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="action_name">win.scan-remote</property>
+                    <property name="label" translatable="yes">Scan Remote Folder</property>
+                    <property name="use_underline">True</property>
+                    <!--<property name="stock_id">gtk-network</property>-->
+                  </object>
+                </child>
               </object>
             </child>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="homogeneous">True</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkToolButton" id="scan-filesystem-button">
-            <property name="use_action_appearance">False</property>
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup" translatable="yes">Scan the file system</property>
-            <property name="tooltip_text" translatable="yes">Scan the file system</property>
-            <property name="use_action_appearance">False</property>
-            <property name="action_name">win.scan-filesystem</property>
-            <property name="label" translatable="yes">Scan File System</property>
-            <property name="use_underline">True</property>
-            <property name="stock_id">gtk-harddisk</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="homogeneous">True</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkToolButton" id="scan-folder-button">
-            <property name="use_action_appearance">False</property>
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup" translatable="yes">Scan a folder</property>
-            <property name="tooltip_text" translatable="yes">Scan a folder</property>
-            <property name="use_action_appearance">False</property>
-            <property name="action_name">win.scan-folder</property>
-            <property name="label" translatable="yes">Scan Folder</property>
-            <property name="use_underline">True</property>
-            <property name="stock_id">gtk-directory</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="homogeneous">True</property>
-          </packing>
         </child>
         <child>
-          <object class="GtkToolButton" id="scan-remote-button">
+          <object class="GtkToolButton" id="show-home-page-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup" translatable="yes">Scan a remote folder</property>
-            <property name="tooltip_text" translatable="yes">Scan a remote folder</property>
+            <property name="is_important">True</property>
+            <property name="tooltip_markup" translatable="yes">Show all locations</property>
+            <property name="tooltip_text" translatable="yes">Show all locations</property>
             <property name="use_action_appearance">False</property>
-            <property name="action_name">win.scan-remote</property>
-            <property name="label" translatable="yes">Scan Remote Folder</property>
+            <property name="action_name">win.show-home-page</property>
+            <property name="label" translatable="yes">All locations</property>
             <property name="use_underline">True</property>
-            <property name="stock_id">gtk-network</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -98,15 +76,16 @@
           <object class="GtkSeparatorToolItem" id="separatortoolitem1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="draw">False</property>
           </object>
           <packing>
-            <property name="expand">False</property>
+            <property name="expand">True</property>
           </packing>
         </child>
         <child>
           <object class="GtkToolButton" id="stop-button">
             <property name="use_action_appearance">False</property>
-            <property name="visible">True</property>
+            <property name="visible">False</property>
             <property name="can_focus">False</property>
             <property name="has_tooltip">True</property>
             <property name="tooltip_markup" translatable="yes">Stop scanning</property>
@@ -198,230 +177,273 @@
           </object>
         </child>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">1</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
     </child>
     <child>
-      <object class="GtkPaned" id="hpaned">
+      <object class="GtkNotebook" id="main-notebook">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="position">480</property>
+        <property name="show_tabs">False</property> -->
+        <property name="show_border">False</property> -->
         <child>
-          <object class="GtkScrolledWindow" id="scrolled-window">
+          <object class="GtkGrid" id="home-page">
+            <property name="can_focus">False</property>
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="shadow_type">in</property>
+            <property name="orientation">vertical</property>
             <child>
-              <object class="GtkTreeView" id="treeview">
+              <object class="GtkScrolledWindow" id="volume-scrolled-window">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection" id="treeview-selection1"/>
-                </child>
+                <property name="vexpand">True</property>
+                <property name="hexpand">True</property>
                 <child>
-                  <object class="GtkTreeViewColumn" id="folder-column">
-                    <property name="resizable">True</property>
-                    <property name="sizing">autosize</property>
-                    <property name="title" translatable="yes">Folder</property>
-                    <property name="expand">True</property>
-                    <property name="reorderable">True</property>
-                    <property name="sort_column_id">0</property>
-                    <child>
-                      <object class="GtkCellRendererText" id="folder-column-text-renderer"/>
-                      <attributes>
-                        <attribute name="text">0</attribute>
-                      </attributes>
-                    </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkTreeViewColumn" id="usage-column">
-                    <property name="sizing">autosize</property>
-                    <property name="title" translatable="yes">Usage</property>
-                    <property name="reorderable">True</property>
-                    <property name="sort_column_id">2</property>
-                    <child>
-                      <object class="BaobabCellRendererProgress" id="usage-column-bar-renderer">
-                        <property name="xpad">4</property>
-                        <property name="ypad">4</property>
-                      </object>
-                      <attributes>
-                        <attribute name="value">2</attribute>
-                      </attributes>
-                    </child>
-                    <child>
-                      <object class="BaobabCellRendererPercent" id="usage-column-percent-renderer">
-                        <property name="xalign">1.0</property>
-                      </object>
-                      <attributes>
-                        <attribute name="percent">2</attribute>
-                      </attributes>
-                    </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkTreeViewColumn" id="size-column">
-                    <property name="resizable">True</property>
-                    <property name="sizing">autosize</property>
-                    <property name="title" translatable="yes">Size</property>
-                    <property name="reorderable">True</property>
-                    <property name="sort_column_id">4</property>
-                    <child>
-                      <object class="BaobabCellRendererSize" id="size-column-size-renderer">
-                        <property name="xalign">1.0</property>
-                        <property name="show-allocated-size">True</property>
-                      </object>
-                      <attributes>
-                        <attribute name="size">3</attribute>
-                        <attribute name="alloc-size">4</attribute>
-                      </attributes>
-                    </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkTreeViewColumn" id="contents-column">
-                    <property name="resizable">True</property>
-                    <property name="sizing">autosize</property>
-                    <property name="title" translatable="yes">Contents</property>
-                    <property name="reorderable">True</property>
-                    <property name="sort_column_id">5</property>
+                  <object class="GtkViewport" id="volume-viewport">
+                    <property name="visible">True</property>
                     <child>
-                      <object class="BaobabCellRendererItems" id="contents-column-items-renderer">
-                        <property name="xalign">1.0</property>
+                      <object class="GtkGrid" id="location-view">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
                       </object>
-                      <attributes>
-                        <attribute name="items">5</attribute>
-                      </attributes>
                     </child>
                   </object>
                 </child>
               </object>
             </child>
-          </object>
-          <packing>
-            <property name="resize">False</property>
-            <property name="shrink">True</property>
-          </packing>
+           </object>
         </child>
         <child>
-          <object class="GtkGrid" id="chart-grid">
+          <object class="GtkGrid" id="result-page">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
             <child>
-              <object class="GtkNotebook" id="chart-notebook">
+              <object class="GtkPaned" id="hpaned">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="show_tabs">False</property>
-                <property name="show_border">False</property>
-                <child>
-                  <object class="BaobabRingschart" id="rings-chart">
-                    <property name="visible">True</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                  </object>
-                </child>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="position">480</property>
                 <child>
-                  <object class="BaobabTreemap" id="treemap-chart">
-                    <property name="visible">True</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkSpinner" id="spinner">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                    <property name="margin_left">24</property>
-                    <property name="margin_right">24</property>
-                    <property name="margin_top">24</property>
-                    <property name="margin_bottom">24</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButtonBox" id="chart-buttonbox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_right">20</property>
-                <property name="margin_top">6</property>
-                <property name="margin_bottom">6</property>
-                <property name="homogeneous">False</property>
-                <property name="layout_style">end</property>
-                <style>
-                  <class name="linked"/>
-                </style>
-                <child>
-                  <object class="GtkRadioButton" id="rings-button">
+                  <object class="GtkScrolledWindow" id="scrolled-window">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="tooltip_markup" translatable="yes">Rings Chart</property>
-                    <property name="xalign">0.5</property>
-                    <property name="yalign">0.5</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">False</property>
-                    <property name="action_name">win.active-chart</property>
-                    <property name="action_target">'rings'</property>
+                    <property name="shadow_type">in</property>
                     <child>
-                      <object class="GtkImage" id="ringschart-icon">
+                      <object class="GtkTreeView" id="treeview">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="icon_name">view-ringschart-symbolic</property>
+                        <property name="can_focus">True</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection1"/>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="folder-column">
+                            <property name="resizable">True</property>
+                            <property name="sizing">autosize</property>
+                            <property name="title" translatable="yes">Folder</property>
+                            <property name="expand">True</property>
+                            <property name="reorderable">True</property>
+                            <property name="sort_column_id">0</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="folder-column-text-renderer"/>
+                              <attributes>
+                                <attribute name="text">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="usage-column">
+                            <property name="sizing">autosize</property>
+                            <property name="title" translatable="yes">Usage</property>
+                            <property name="reorderable">True</property>
+                            <property name="sort_column_id">2</property>
+                            <child>
+                              <object class="BaobabCellRendererProgress" id="usage-column-bar-renderer">
+                                <property name="xpad">4</property>
+                                <property name="ypad">4</property>
+                              </object>
+                              <attributes>
+                                <attribute name="value">2</attribute>
+                              </attributes>
+                            </child>
+                            <child>
+                              <object class="BaobabCellRendererPercent" id="usage-column-percent-renderer">
+                                <property name="xalign">1.0</property>
+                              </object>
+                              <attributes>
+                                <attribute name="percent">2</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="size-column">
+                            <property name="resizable">True</property>
+                            <property name="sizing">autosize</property>
+                            <property name="title" translatable="yes">Size</property>
+                            <property name="reorderable">True</property>
+                            <property name="sort_column_id">4</property>
+                            <child>
+                              <object class="BaobabCellRendererSize" id="size-column-size-renderer">
+                                <property name="xalign">1.0</property>
+                                <property name="show-allocated-size">True</property>
+                              </object>
+                              <attributes>
+                                <attribute name="size">3</attribute>
+                                <attribute name="alloc-size">4</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="contents-column">
+                            <property name="resizable">True</property>
+                            <property name="sizing">autosize</property>
+                            <property name="title" translatable="yes">Contents</property>
+                            <property name="reorderable">True</property>
+                            <property name="sort_column_id">5</property>
+                            <child>
+                              <object class="BaobabCellRendererItems" id="contents-column-items-renderer">
+                                <property name="xalign">1.0</property>
+                              </object>
+                              <attributes>
+                                <attribute name="items">5</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                    <property name="non_homogeneous">True</property>
+                    <property name="resize">False</property>
+                    <property name="shrink">True</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkRadioButton" id="treemap-button">
+                  <object class="GtkGrid" id="chart-grid">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="tooltip_markup" translatable="yes">Treemap Chart</property>
-                    <property name="xalign">0.5</property>
-                    <property name="yalign">0.5</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">False</property>
-                    <property name="group">rings-button</property>
-                    <property name="action_name">win.active-chart</property>
-                    <property name="action_target">'treemap'</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
                     <child>
-                      <object class="GtkImage" id="treemap-icon">
+                      <object class="GtkNotebook" id="chart-notebook">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="show_tabs">False</property>
+                        <property name="show_border">False</property>
+                        <child>
+                          <object class="BaobabRingschart" id="rings-chart">
+                            <property name="visible">True</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="BaobabTreemap" id="treemap-chart">
+                            <property name="visible">True</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkSpinner" id="spinner">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="margin_left">24</property>
+                            <property name="margin_right">24</property>
+                            <property name="margin_top">24</property>
+                            <property name="margin_bottom">24</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButtonBox" id="chart-buttonbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="icon_name">view-treemap-symbolic</property>
+                        <property name="margin_right">20</property>
+                        <property name="margin_top">6</property>
+                        <property name="margin_bottom">6</property>
+                        <property name="homogeneous">False</property>
+                        <property name="layout_style">end</property>
+                        <style>
+                          <class name="linked"/>
+                        </style>
+                        <child>
+                          <object class="GtkRadioButton" id="rings-button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="tooltip_markup" translatable="yes">Rings Chart</property>
+                            <property name="xalign">0.5</property>
+                            <property name="yalign">0.5</property>
+                            <property name="active">True</property>
+                            <property name="draw_indicator">False</property>
+                            <property name="action_name">win.active-chart</property>
+                            <property name="action_target">'rings'</property>
+                            <child>
+                              <object class="GtkImage" id="ringschart-icon">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="icon_name">view-ringschart-symbolic</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                            <property name="non_homogeneous">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkRadioButton" id="treemap-button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="tooltip_markup" translatable="yes">Treemap Chart</property>
+                            <property name="xalign">0.5</property>
+                            <property name="yalign">0.5</property>
+                            <property name="active">True</property>
+                            <property name="draw_indicator">False</property>
+                            <property name="group">rings-button</property>
+                            <property name="action_name">win.active-chart</property>
+                            <property name="action_target">'treemap'</property>
+                            <child>
+                              <object class="GtkImage" id="treemap-icon">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="icon_name">view-treemap-symbolic</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                            <property name="non_homogeneous">True</property>
+                          </packing>
+                        </child>
                       </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                    <property name="non_homogeneous">True</property>
+                    <property name="resize">True</property>
+                    <property name="shrink">True</property>
                   </packing>
                 </child>
               </object>
@@ -433,18 +455,8 @@
               </packing>
             </child>
           </object>
-          <packing>
-            <property name="resize">True</property>
-            <property name="shrink">True</property>
-          </packing>
         </child>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">2</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
     </child>
   </object>
   <object class="GtkMenu" id="treeview-popup-menu">
diff --git a/src/baobab-menu.ui b/src/baobab-menu.ui
index 41e139b..c78479a 100644
--- a/src/baobab-menu.ui
+++ b/src/baobab-menu.ui
@@ -4,16 +4,16 @@
   <menu id="appmenu">
     <section>
       <item>
+        <attribute name="label" translatable="yes">_All locations</attribute>
+        <attribute name="action">win.show-home-page</attribute>
+        <attribute name="accel">&lt;Primary&gt;a</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_Scan Home</attribute>
         <attribute name="action">win.scan-home</attribute>
         <attribute name="accel">&lt;Primary&gt;h</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">Scan _Filesystem</attribute>
-        <attribute name="action">win.scan-filesystem</attribute>
-        <attribute name="accel">&lt;Primary&gt;f</attribute>
-      </item>
-      <item>
         <attribute name="label" translatable="yes">Scan F_olderâ</attribute>
         <attribute name="action">win.scan-folder</attribute>
         <attribute name="accel">&lt;Primary&gt;o</attribute>
@@ -58,16 +58,16 @@
       <attribute name="label" translatable="yes">_Analizer</attribute>
       <section>
         <item>
+          <attribute name="label" translatable="yes">_All locations</attribute>
+          <attribute name="action">win.show-home-page</attribute>
+          <attribute name="accel">&lt;Primary&gt;a</attribute>
+        </item>
+        <item>
           <attribute name="label" translatable="yes">_Scan Home</attribute>
           <attribute name="action">win.scan-home</attribute>
           <attribute name="accel">&lt;Primary&gt;h</attribute>
         </item>
         <item>
-          <attribute name="label" translatable="yes">Scan _Filesystem</attribute>
-          <attribute name="action">win.scan-filesystem</attribute>
-          <attribute name="accel">&lt;Primary&gt;f</attribute>
-        </item>
-        <item>
           <attribute name="label" translatable="yes">Scan F_olderâ</attribute>
           <attribute name="action">win.scan-folder</attribute>
           <attribute name="accel">&lt;Primary&gt;o</attribute>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 5a32be9..d2be201 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -1,15 +1,22 @@
 namespace Baobab {
 	public class Window : Gtk.ApplicationWindow {
 		Settings ui_settings;
+		Gtk.Notebook main_notebook;
+		Gtk.Toolbar toolbar;
+		Gtk.ToolItem toolbar_home_toolitem;
+		Gtk.ToolButton toolbar_show_home_page;
+		Gtk.ToolButton toolbar_rescan;
 		Gtk.InfoBar infobar;
 		Gtk.Label infobar_primary;
 		Gtk.Label infobar_secondary;
 		Gtk.TreeView treeview;
 		Gtk.Notebook chart_notebook;
+		Gtk.Grid location_view;
 		Chart rings_chart;
 		Chart treemap_chart;
 		Gtk.Spinner spinner;
 		Scanner? scanner;
+		LocationMonitor location_monitor;
 
 		static Gdk.Cursor busy_cursor;
 
@@ -18,9 +25,9 @@ namespace Baobab {
 		}
 
 		private const GLib.ActionEntry[] action_entries = {
+			{ "show-home-page", on_show_home_page_activate },
 			{ "active-chart", radio_activate, "s", "'rings'", on_chart_type_changed },
 			{ "scan-home", on_scan_home_activate },
-			{ "scan-filesystem", on_scan_filesystem_activate },
 			{ "scan-folder", on_scan_folder_activate },
 			{ "scan-remote", on_scan_remote_activate },
 			{ "stop", on_stop_activate },
@@ -40,7 +47,6 @@ namespace Baobab {
 
 		private const ActionState[] actions_while_scanning = {
 			{ "scan-home", false },
-			{ "scan-filesystem", false },
 			{ "scan-folder", false },
 			{ "scan-remote", false },
 			{ "stop", true },
@@ -50,6 +56,11 @@ namespace Baobab {
 			{ "collapse-all", false }
 		};
 
+		private enum UIPage {
+			HOME,
+			RESULT
+		}
+
 		private enum ChartPage {
 			RINGS,
 			TREEMAP,
@@ -79,7 +90,13 @@ namespace Baobab {
 				error ("loading main builder file: %s", e.message);
 			}
 
+
 			// Cache some objects from the builder.
+			main_notebook = builder.get_object ("main-notebook") as Gtk.Notebook;
+			toolbar = builder.get_object ("toolbar") as Gtk.Toolbar;
+			toolbar_home_toolitem = builder.get_object ("home-page-toolitem") as Gtk.ToolItem;
+			toolbar_show_home_page = builder.get_object ("show-home-page-button") as Gtk.ToolButton;
+			toolbar_rescan = builder.get_object ("rescan-button") as Gtk.ToolButton;
 			infobar = builder.get_object ("infobar") as Gtk.InfoBar;
 			infobar_primary = builder.get_object ("infobar-primary-label") as Gtk.Label;
 			infobar_secondary = builder.get_object ("infobar-secondary-label") as Gtk.Label;
@@ -88,9 +105,14 @@ namespace Baobab {
 			rings_chart = builder.get_object ("rings-chart") as Chart;
 			treemap_chart = builder.get_object ("treemap-chart") as Chart;
 			spinner = builder.get_object ("spinner") as Gtk.Spinner;
+			location_view = builder.get_object ("location-view") as Gtk.Grid;
 
+			setup_home_page ();
 			setup_treeview (builder);
 
+			// To make it draggable like a primary toolbar
+			toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
+
 			ui_settings = Application.get_ui_settings ();
 			lookup_action ("active-chart").change_state (ui_settings.get_value ("active-chart"));
 
@@ -104,12 +126,31 @@ namespace Baobab {
 			add (builder.get_object ("window-contents") as Gtk.Widget);
 			title = _("Disk Usage Analyzer");
 			set_default_size (800, 500);
+			set_hide_titlebar_when_maximized (true);
+
+			set_ui_page (UIPage.HOME);
 
 			set_busy (false);
 
 			show ();
 		}
 
+		void set_ui_page (UIPage page) {
+			toolbar_home_toolitem.visible = (page == UIPage.HOME);
+			toolbar_show_home_page.visible = (page == UIPage.RESULT);
+			toolbar_rescan.visible = (page == UIPage.RESULT);
+
+			main_notebook.page = page;
+		}
+
+		void on_show_home_page_activate () {
+			if (scanner != null) {
+				scanner.cancel ();
+			}
+
+			set_ui_page (UIPage.HOME);
+		}
+
 		void on_chart_type_changed (SimpleAction action, Variant value) {
 			switch (value as string) {
 				case "rings":
@@ -131,11 +172,6 @@ namespace Baobab {
 			scan_directory (dir);
 		}
 
-		void on_scan_filesystem_activate () {
-			var dir = File.new_for_uri ("file:///");
-			scan_directory (dir);
-		}
-
 		void on_scan_folder_activate () {
 			var file_chooser = new Gtk.FileChooserDialog (_("Select Folder"), this,
 			                                              Gtk.FileChooserAction.SELECT_FOLDER,
@@ -268,6 +304,40 @@ namespace Baobab {
 			Gtk.drag_dest_unset (this);
 		}
 
+		void update_locations () {
+			location_view.foreach ((widget) => { widget.destroy (); });
+
+			foreach (var location in location_monitor.get_locations ()) {
+				LocationWidget loc_widget;
+				if (location.is_home_location) {
+					loc_widget = new LocationWidget (location, (location_) => {
+						on_scan_home_activate ();
+					});
+				} else {
+					loc_widget = new LocationWidget (location, (location_) => {
+						location_.mount_volume.begin ((location__, res) => {
+							try {
+								location_.mount_volume.end (res);
+								scan_directory (File.new_for_path (location_.mount_point), ScanFlags.EXCLUDE_MOUNTS);
+							} catch (Error e) {
+								message (_("Could not analyze volume."), e.message, Gtk.MessageType.ERROR);
+							}
+						});
+					});
+				}
+
+				location_view.add (loc_widget);
+			}
+
+			location_view.show_all ();
+		}
+
+		void setup_home_page () {
+			location_monitor = LocationMonitor.get ();
+			location_monitor.changed.connect (() => { update_locations (); });
+			update_locations ();
+		}
+
 		bool show_treeview_popup (Gtk.Menu popup, Gdk.EventButton? event) {
 			if (event != null) {
 				popup.popup (null, null, null, event.button, event.time);
@@ -364,6 +434,7 @@ namespace Baobab {
 				(lookup_action ("active-chart") as SimpleAction).set_enabled (false);
 				chart_notebook.page = ChartPage.SPINNER;
 				spinner.start ();
+				toolbar_show_home_page.label = _("Cancel scan");
 			} else {
 				enable_drop ();
 				rings_chart.thaw_updates ();
@@ -371,6 +442,7 @@ namespace Baobab {
 				(lookup_action ("active-chart") as SimpleAction).set_enabled (true);
 				spinner.stop ();
 				lookup_action ("active-chart").change_state (ui_settings.get_value ("active-chart"));
+				toolbar_show_home_page.label = _("All locations");
 			}
 
 			var window = get_window ();
@@ -436,21 +508,6 @@ namespace Baobab {
 			                                    Scanner.Columns.ELEMENTS, null);
 		}
 
-		public void show_filesystem_usage () {
-			var dir = File.new_for_uri ("file:///");
-
-			scanner = new ThreadedScanner (dir, ScanFlags.NONE);
-			set_model (scanner);
-
-			try {
-				scanner.get_filesystem_usage ();
-			} catch (Error e) {
-				message (_("Could not get filesytem usage."), e.message, Gtk.MessageType.WARNING);
-			}
-
-			treeview.set_headers_visible (false);
-		}
-
 		public void scan_directory (File directory, ScanFlags flags = ScanFlags.NONE) {
 			if (!check_dir (directory)) {
 				return;
@@ -466,7 +523,6 @@ namespace Baobab {
 				} catch (IOError.CANCELLED e) {
 					// Handle cancellation silently
 					scanner.clear ();
-					show_filesystem_usage ();
 				} catch (Error e) {
 					var primary = _("Could not scan folder \"%s\" or some of the folders it contains.").printf (scanner.directory.get_parse_name ());
 					message (primary, e.message, Gtk.MessageType.WARNING);
@@ -474,7 +530,8 @@ namespace Baobab {
 			});
 
 			clear_message ();
-			treeview.set_headers_visible (true);
+
+			set_ui_page (UIPage.RESULT);
 			set_busy (true);
 
 			scanner.scan ();



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