[baobab/wip/vala: 41/41] Pass the directory in the scanner constructor.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 41/41] Pass the directory in the scanner constructor.
- Date: Sun, 8 Jan 2012 19:16:00 +0000 (UTC)
commit 781539c8d6d240d63b895f700b94c7aeea02e0e3
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jan 8 19:59:38 2012 +0100
Pass the directory in the scanner constructor.
We decided that scanner is a single use object that is reinstanciated
every time a new dir is scannedl, so it is cleaner to just take the dir
in the constructor instead of requiring a separate method.
src/baobab-scanner.vala | 21 ++++++++++-----------
src/baobab-sync-scanner.vala | 7 +++++--
src/baobab-threaded-scanner.vala | 12 ++++--------
src/baobab-window.vala | 4 +---
4 files changed, 20 insertions(+), 24 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index b27d5c2..5c2435f 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -43,9 +43,7 @@ namespace Baobab {
FILE_ATTRIBUTE_UNIX_DEVICE + "," +
FILE_ATTRIBUTE_ACCESS_CAN_READ;
- public File directory { get; protected set; }
-
- public abstract void scan (File directory);
+ public File directory { get; private set; }
public int max_depth { get; protected set; }
@@ -53,15 +51,16 @@ namespace Baobab {
cancellable.cancel ();
}
- public Scanner () {
+ public Scanner (File directory) {
+ this.directory = directory;
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 (string), // DIR_NAME
+ typeof (string), // PARSE_NAME
+ typeof (double), // PERCENT
+ typeof (uint64), // SIZE
+ typeof (uint64), // ALLOC_SIZE
+ typeof (int), // ELEMENTS
+ typeof (State)}); // STATE
set_sort_column_id (Columns.SIZE, Gtk.SortType.DESCENDING);
excluded_locations = Application.get_excluded_locations ();
}
diff --git a/src/baobab-sync-scanner.vala b/src/baobab-sync-scanner.vala
index fc0fb6e..f0e0b0e 100644
--- a/src/baobab-sync-scanner.vala
+++ b/src/baobab-sync-scanner.vala
@@ -109,8 +109,7 @@ namespace Baobab {
}
}
- protected override void scan (File directory) {
- this.directory = directory;
+ public void scan () {
try {
var info = directory.query_info (ATTRIBUTES, 0, cancellable);
var results = add_directory (directory, info);
@@ -118,5 +117,9 @@ namespace Baobab {
max_depth = results.max_depth;
} catch { }
}
+
+ public SyncScanner (File directory) {
+ base (directory);
+ }
}
}
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index be1e345..25f19f9 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -208,15 +208,15 @@ namespace Baobab {
max_depth = results.max_depth;
}
}
-
}
return this.self != null;
}
- protected override void scan (File directory) {
- this.directory = directory;
- this.excluded_locations = Application.get_excluded_locations ();
+ public ThreadedScanner (File directory) {
+ base (directory);
+
+ results_queue = new AsyncQueue<ResultsArray> ();
// the thread owns a reference on the Scanner object
this.self = this;
@@ -225,9 +225,5 @@ namespace Baobab {
Timeout.add (100, process_results);
}
-
- public ThreadedScanner () {
- results_queue = new AsyncQueue<ResultsArray> ();
- }
}
}
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index beac701..aa114d4 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -234,9 +234,7 @@ namespace Baobab {
set_busy (true);
- scanner = new ThreadedScanner ();
- scanner.scan (directory);
-
+ scanner = new ThreadedScanner (directory);
set_model (scanner);
set_busy (false);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]