[baobab/wip/vala: 20/53] First cut at stop and refresh.
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 20/53] First cut at stop and refresh.
- Date: Thu, 5 Apr 2012 21:35:24 +0000 (UTC)
commit 85fb4d65b70df2b35e6116df5777c5a1f14d3f6d
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Jan 6 12:21:30 2012 +0100
First cut at stop and refresh.
I need to check with Ryan if he intends the scanner object to be
reusable or recreated each time.
src/baobab-scanner.vala | 7 ++++++-
src/baobab-window.vala | 11 ++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index ccea96c..bc54912 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -28,7 +28,7 @@ namespace Baobab {
}
}
- protected Cancellable? cancellable;
+ protected Cancellable cancellable;
protected HardLink[] hardlinks;
protected static const string ATTRIBUTES =
@@ -48,7 +48,12 @@ namespace Baobab {
public int max_depth { get; protected set; }
+ public virtual void stop () {
+ cancellable.cancel ();
+ }
+
public Scanner () {
+ cancellable = new Cancellable();
set_column_types (new Type[] {
typeof (string), /* DIR_NAME */
typeof (string), /* PARSE_NAME */
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 3513cb5..3b3a377 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -3,6 +3,7 @@ namespace Baobab {
Gtk.TreeView treeview;
Chart rings_chart;
Chart treemap;
+ Scanner? scanner;
private const GLib.ActionEntry[] action_entries = {
{ "scan-home", on_scan_home_activate },
@@ -96,11 +97,15 @@ namespace Baobab {
}
void on_stop_activate () {
- print ("s\n");
+ if (scanner != null) {
+ scanner.stop ();
+ }
}
void on_refresh_activate () {
- print ("r\n");
+ if (scanner != null) {
+ scan_directory (scanner.directory);
+ }
}
void on_drag_data_received (Gtk.Widget widget, Gdk.DragContext context, int x, int y,
@@ -201,7 +206,7 @@ namespace Baobab {
disable_drop ();
- var scanner = new ThreadedScanner ();
+ scanner = new ThreadedScanner ();
scanner.scan (directory);
set_model (scanner);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]