[baobab/wip/vala: 20/53] First cut at stop and refresh.
- From: Paolo Borelli <pborelli 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 22:03:14 +0000 (UTC)
commit 063f39d89f3bf9674ed6e1fd8530b100a83176fb
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 c67b0d3..66d50a7 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -48,7 +48,7 @@ namespace Baobab {
}
}
- protected Cancellable? cancellable;
+ protected Cancellable cancellable;
protected HardLink[] hardlinks;
protected static const string ATTRIBUTES =
@@ -68,7 +68,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 1f00f1f..8a4822e 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -23,6 +23,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 },
@@ -116,11 +117,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,
@@ -221,7 +226,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]