[baobab/wip/vala: 35/44] First cut at stop and refresh.



commit 62292da74d9b7a10527c4584c6c7ab2cddc335fd
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 |    4 ++++
 src/baobab-window.vala  |   11 ++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index ccea96c..affee14 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -48,6 +48,10 @@ namespace Baobab {
 
 		public int max_depth { get; protected set; }
 
+		public virtual void stop () {
+			cancellable.cancel ();
+		}
+
 		public Scanner () {
 			set_column_types (new Type[] {
 			                  typeof (string),  /* DIR_NAME */
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index b427c09..6d29c42 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       },
@@ -81,11 +82,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,
@@ -186,7 +191,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]