[baobab/wip/vala: 52/53] Add an (optional) scanning flag parameter to exclude mount points
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 52/53] Add an (optional) scanning flag parameter to exclude mount points
- Date: Thu, 5 Apr 2012 21:38:06 +0000 (UTC)
commit 7e269681d28e1b783954fb97c2f3d447c8698f3a
Author: Stefano Facchini <stefano facchini gmail com>
Date: Thu Apr 5 21:08:43 2012 +0200
Add an (optional) scanning flag parameter to exclude mount points
src/baobab-scanner.vala | 38 ++++++++++++++++++++++++++++----------
src/baobab-sync-scanner.vala | 4 ++--
src/baobab-threaded-scanner.vala | 4 ++--
src/baobab-window.vala | 8 ++++----
4 files changed, 36 insertions(+), 18 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 071f6da..e1b1f50 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -1,4 +1,10 @@
namespace Baobab {
+ [Flags]
+ public enum ScanFlags {
+ NONE,
+ EXCLUDE_MOUNTS
+ }
+
abstract class Scanner : Gtk.TreeStore {
public enum Columns {
DISPLAY_NAME,
@@ -40,7 +46,7 @@ namespace Baobab {
FileAttribute.STANDARD_DISPLAY_NAME + "," +
FileAttribute.STANDARD_TYPE + "," +
FileAttribute.STANDARD_SIZE + "," +
- FileAttribute.STANDARD_ALLOCATED_SIZE + "," +
+ FileAttribute.STANDARD_ALLOCATED_SIZE + "," +
FileAttribute.UNIX_NLINK + "," +
FileAttribute.UNIX_INODE + "," +
FileAttribute.UNIX_DEVICE + "," +
@@ -48,6 +54,8 @@ namespace Baobab {
public File directory { get; private set; }
+ public ScanFlags scan_flags { get; private set; }
+
public int max_depth { get; protected set; }
public signal void completed();
@@ -115,21 +123,31 @@ namespace Baobab {
Columns.ERROR, null);
}
- public Scanner (File directory) {
+ public Scanner (File directory, ScanFlags flags) {
this.directory = directory;
+ this.scan_flags = flags;
cancellable = new Cancellable();
scan_error = null;
set_column_types (new Type[] {
- typeof (string), // DIR_NAME
- typeof (string), // PARSE_NAME
- typeof (double), // PERCENT
- typeof (uint64), // SIZE
- typeof (uint64), // ALLOC_SIZE
- typeof (int), // ELEMENTS
- typeof (State), // STATE
- typeof (Error)}); // ERROR (if STATE is ERROR)
+ typeof (string), // DIR_NAME
+ typeof (string), // PARSE_NAME
+ typeof (double), // PERCENT
+ typeof (uint64), // SIZE
+ typeof (uint64), // ALLOC_SIZE
+ typeof (int), // ELEMENTS
+ typeof (State), // STATE
+ typeof (Error)}); // ERROR (if STATE is ERROR)
set_sort_column_id (Columns.SIZE, Gtk.SortType.DESCENDING);
+
excluded_locations = Application.get_excluded_locations ();
+
+ if (ScanFlags.EXCLUDE_MOUNTS in flags) {
+ foreach (unowned UnixMountEntry mount in UnixMountEntry.get (null)) {
+ excluded_locations.add (File.new_for_path (mount.get_mount_path ()));
+ }
+ }
+
+ excluded_locations.remove (directory);
}
}
}
diff --git a/src/baobab-sync-scanner.vala b/src/baobab-sync-scanner.vala
index 2b1a236..775bbfe 100644
--- a/src/baobab-sync-scanner.vala
+++ b/src/baobab-sync-scanner.vala
@@ -118,8 +118,8 @@ namespace Baobab {
} catch { }
}
- public SyncScanner (File directory) {
- base (directory);
+ public SyncScanner (File directory, ScanFlags flags) {
+ base (directory, flags);
}
}
}
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index 8e92ef1..771f82b 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -235,8 +235,8 @@ namespace Baobab {
Timeout.add (100, process_results);
}
- public ThreadedScanner (File directory) {
- base (directory);
+ public ThreadedScanner (File directory, ScanFlags flags) {
+ base (directory, flags);
results_queue = new AsyncQueue<ResultsArray> ();
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index c9c4abf..5a32be9 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -176,7 +176,7 @@ namespace Baobab {
void on_reload_activate () {
if (scanner != null) {
- scan_directory (scanner.directory);
+ scan_directory (scanner.directory, scanner.scan_flags);
}
}
@@ -439,7 +439,7 @@ namespace Baobab {
public void show_filesystem_usage () {
var dir = File.new_for_uri ("file:///");
- scanner = new ThreadedScanner (dir);
+ scanner = new ThreadedScanner (dir, ScanFlags.NONE);
set_model (scanner);
try {
@@ -451,12 +451,12 @@ namespace Baobab {
treeview.set_headers_visible (false);
}
- public void scan_directory (File directory) {
+ public void scan_directory (File directory, ScanFlags flags = ScanFlags.NONE) {
if (!check_dir (directory)) {
return;
}
- scanner = new ThreadedScanner (directory);
+ scanner = new ThreadedScanner (directory, flags);
set_model (scanner);
scanner.completed.connect(() => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]