[baobab/wip/vala: 29/53] First cut at action sensitivity.



commit 35eaedbe45716d507232e227a65822c2ceda60d4
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Jan 17 00:49:24 2012 +0100

    First cut at action sensitivity.

 data/baobab-main-window.ui |    6 +++---
 src/baobab-window.vala     |   26 +++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/data/baobab-main-window.ui b/data/baobab-main-window.ui
index a259707..681ee76 100644
--- a/data/baobab-main-window.ui
+++ b/data/baobab-main-window.ui
@@ -126,11 +126,11 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup" translatable="yes">Refresh</property>
-            <property name="tooltip_text" translatable="yes">Refresh</property>
+            <property name="tooltip_markup" translatable="yes">Reload</property>
+            <property name="tooltip_text" translatable="yes">Reload</property>
             <property name="use_action_appearance">False</property>
             <property name="stock_id">gtk-refresh</property>
-            <property name="action_name">win.refresh</property>
+            <property name="action_name">win.reload</property>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index edc1b73..008891a 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -42,6 +42,23 @@ namespace Baobab {
 			{ "collapse-all", on_collapse_all }
 		};
 
+		protected struct ActionState {
+			string name;
+			bool enable;
+		}
+
+		private const ActionState[] actions_while_scanning = {
+			{ "scan-home", false },
+			{ "scan-filesystem", false },
+			{ "scan-folder", false },
+			{ "scan-remote", false },
+			{ "stop", true },
+			{ "reload", false },
+			{ "show-allocated", false },
+			{ "expand-all", false },
+			{ "collapse-all", false }
+		};
+
 		private enum DndTargets {
 			URI_LIST
 		}
@@ -86,10 +103,12 @@ namespace Baobab {
 			drag_data_received.connect(on_drag_data_received);
 			enable_drop ();
 
-			// Go live.
 			add (builder.get_object ("window-contents") as Gtk.Widget);
 			title = _("Disk Usage Analyzer");
 			set_default_size (800, 500);
+
+			set_busy (false);
+
 			show ();
 		}
 
@@ -214,6 +233,11 @@ namespace Baobab {
 			if (window != null) {
 				window.set_cursor (cursor);
 			}
+
+			foreach (ActionState action_state in actions_while_scanning) {
+				var action = lookup_action (action_state.name) as SimpleAction;
+				action.set_enabled (busy == action_state.enable);
+			}
 		}
 
 		public bool check_dir (File directory) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]