[baobab/wip/new-design] Implement automatic handling of 'Home folder' location
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/new-design] Implement automatic handling of 'Home folder' location
- Date: Thu, 5 Apr 2012 08:45:33 +0000 (UTC)
commit 4e9e4a3c03ec6d32ab15fe3ba6938fae7d3671b2
Author: Stefano Facchini <stefano facchini gmail com>
Date: Wed Apr 4 14:46:12 2012 +0200
Implement automatic handling of 'Home folder' location
src/baobab-location-monitor.vala | 4 +++
src/baobab-location.vala | 32 +++++++++++++++++++++++++++++-
src/baobab-window.vala | 39 +++++++++++++++++--------------------
3 files changed, 52 insertions(+), 23 deletions(-)
---
diff --git a/src/baobab-location-monitor.vala b/src/baobab-location-monitor.vala
index 2476164..f441b02 100644
--- a/src/baobab-location-monitor.vala
+++ b/src/baobab-location-monitor.vala
@@ -85,6 +85,10 @@ namespace Baobab {
}
}
+ if (Location.get_home_location () == null) {
+ locations.append(new Location.for_home_folder ());
+ }
+
changed ();
}
}
diff --git a/src/baobab-location.vala b/src/baobab-location.vala
index 17f2c7a..9eba222 100644
--- a/src/baobab-location.vala
+++ b/src/baobab-location.vala
@@ -14,6 +14,18 @@ namespace Baobab {
FileAttribute.FILESYSTEM_SIZE + "," +
FileAttribute.FILESYSTEM_USED;
+ private static Location? home_location = null;
+
+ public static Location get_home_location () {
+ return home_location;
+ }
+
+ public bool is_home_location {
+ get {
+ return (this == home_location);
+ }
+ }
+
public Location.from_volume (Volume volume_) {
volume = volume_;
volume.changed.connect((vol) => {
@@ -41,6 +53,11 @@ namespace Baobab {
used = used_;
}
+ public Location.for_home_folder () {
+ mount_point = Environment.get_home_dir ();
+ make_this_home_location ();
+ }
+
public Location (string name_,
string? mount_point_,
uint64? size_,
@@ -53,6 +70,13 @@ namespace Baobab {
icon = icon_;
}
+ void make_this_home_location () {
+ name = _("Home folder");
+ icon = new ThemedIcon (Gtk.Stock.HOME);
+
+ home_location = this;
+ }
+
void update_volume_info () {
mount = volume.get_mount ();
@@ -69,8 +93,14 @@ namespace Baobab {
void fill_from_mount () {
name = mount.get_name ();
+ icon = mount.get_icon ();
var file = mount.get_root ();
+ mount_point = file.get_path ();
+
+ if (mount_point == Environment.get_home_dir ()) {
+ make_this_home_location ();
+ }
uint64? size_ = null;
uint64? used_ = null;
@@ -78,8 +108,6 @@ namespace Baobab {
size = size_;
used = used_;
- mount_point = file.get_path ();
- icon = mount.get_icon ();
}
static void get_fs_size (File file, out uint64? size, out uint64? used) {
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 80ce336..42d4522 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -311,32 +311,29 @@ namespace Baobab {
location_view.foreach ((widget) => { widget.destroy (); });
foreach (var location in location_monitor.get_locations ()) {
- var loc_widget = new LocationWidget (location, (location_) => {
- location_.mount_volume.begin ((location__, res) => {
- try {
- location_.mount_volume.end (res);
- set_ui_page (UIPage.RESULT);
- 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);
- }
+ 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);
+ set_ui_page (UIPage.RESULT);
+ 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);
}
- var home_loc = new Location (_("Home folder"),
- GLib.Environment.get_home_dir (),
- null,
- null,
- new ThemedIcon (Gtk.Stock.HOME));
-
- location_view.add (new LocationWidget (home_loc, (location) => {
- on_scan_home_activate ();
- }));
-
location_view.show_all ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]