[baobab/wip/vala: 27/53] Add a "completed" signal to the scanner
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 27/53] Add a "completed" signal to the scanner
- Date: Thu, 5 Apr 2012 22:03:49 +0000 (UTC)
commit bbdf786ccbc56ebb056b45235dfb58d3d8b71837
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jan 8 22:48:52 2012 +0100
Add a "completed" signal to the scanner
Use the new signal to update the window state when the scan is
completed.
src/baobab-scanner.vala | 4 +++-
src/baobab-threaded-scanner.vala | 4 ++++
src/baobab-window.vala | 10 ++++++----
3 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 1ffefcd..9451c47 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -67,9 +67,11 @@ namespace Baobab {
public int max_depth { get; protected set; }
+ public signal void completed();
+
public abstract void scan ();
- public virtual void stop () {
+ public virtual void cancel () {
cancellable.cancel ();
}
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index 80c39d2..e05f719 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -227,6 +227,10 @@ namespace Baobab {
if (results.max_depth > max_depth) {
max_depth = results.max_depth;
}
+
+ if (results.parent == null) {
+ completed ();
+ }
}
}
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 1b7ea4f..b683628 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -123,7 +123,7 @@ namespace Baobab {
void on_stop_activate () {
if (scanner != null) {
- scanner.stop ();
+ scanner.cancel ();
}
}
@@ -244,6 +244,11 @@ namespace Baobab {
Scanner.Columns.PARSE_NAME,
Scanner.Columns.PERCENT,
Scanner.Columns.ELEMENTS, null);
+
+ set_busy (true);
+ scanner.completed.connect(() => {
+ set_busy (false);
+ });
}
public void scan_directory (File directory) {
@@ -251,13 +256,10 @@ namespace Baobab {
return;
}
- set_busy (true);
-
scanner = new ThreadedScanner (directory);
set_model (scanner);
scanner.scan ();
- set_busy (false);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]