[baobab: 53/53] Start implementing new design
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab: 53/53] Start implementing new design
- Date: Thu, 5 Apr 2012 22:11:21 +0000 (UTC)
commit f53e468df576a7a4745ceac325d5da0bf267619c
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'.
In 'All locations' we show a list of all available volumes, while
'Result' roughly corresponds to the content of the old window. Also,
rework the toolbar to make it more similar to other GNOME apps.
src/baobab-application.vala | 4 +-
src/baobab-main-window.ui | 532 ++++++++++++++++++++++---------------------
src/baobab-menu.ui | 20 +-
src/baobab-window.vala | 105 +++++++--
4 files changed, 365 insertions(+), 296 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index 61619a8..08832bf 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -2,6 +2,7 @@
*
* Copyright (C) 2012 Ryan Lortie <desrt desrt ca>
* Copyright (C) 2012 Paolo Borelli <pborelli gnome org>
+ * Copyright (C) 2012 Stefano Facchini <stefano facchini gmail com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -31,8 +32,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"><Primary>a</attribute>
+ </item>
+ <item>
<attribute name="label" translatable="yes">_Scan Home</attribute>
<attribute name="action">win.scan-home</attribute>
<attribute name="accel"><Primary>h</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Scan _Filesystem</attribute>
- <attribute name="action">win.scan-filesystem</attribute>
- <attribute name="accel"><Primary>f</attribute>
- </item>
- <item>
<attribute name="label" translatable="yes">Scan F_olderâ</attribute>
<attribute name="action">win.scan-folder</attribute>
<attribute name="accel"><Primary>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"><Primary>a</attribute>
+ </item>
+ <item>
<attribute name="label" translatable="yes">_Scan Home</attribute>
<attribute name="action">win.scan-home</attribute>
<attribute name="accel"><Primary>h</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Scan _Filesystem</attribute>
- <attribute name="action">win.scan-filesystem</attribute>
- <attribute name="accel"><Primary>f</attribute>
- </item>
- <item>
<attribute name="label" translatable="yes">Scan F_olderâ</attribute>
<attribute name="action">win.scan-folder</attribute>
<attribute name="accel"><Primary>o</attribute>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 52233d7..c4e24df 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -22,15 +22,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;
@@ -39,9 +46,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 },
@@ -61,7 +68,6 @@ namespace Baobab {
private const ActionState[] actions_while_scanning = {
{ "scan-home", false },
- { "scan-filesystem", false },
{ "scan-folder", false },
{ "scan-remote", false },
{ "stop", true },
@@ -71,6 +77,11 @@ namespace Baobab {
{ "collapse-all", false }
};
+ private enum UIPage {
+ HOME,
+ RESULT
+ }
+
private enum ChartPage {
RINGS,
TREEMAP,
@@ -100,7 +111,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;
@@ -109,9 +126,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"));
@@ -125,12 +147,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":
@@ -152,11 +193,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,
@@ -289,6 +325,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);
@@ -385,6 +455,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 ();
@@ -392,6 +463,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 ();
@@ -457,21 +529,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;
@@ -487,7 +544,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);
@@ -495,7 +551,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]