[baobab] First cut at actovate on click



commit 0f959e7d458e327fcbb49e759a23cbb48e185880
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Jul 31 18:38:28 2012 +0200

    First cut at actovate on click
    
    Remove the location buttons and start the scan on click

 src/baobab-location-list.vala   |   15 ++++++++++++---
 src/baobab-location-widget.vala |   13 +------------
 2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/baobab-location-list.vala b/src/baobab-location-list.vala
index 21b217a..f4018c9 100644
--- a/src/baobab-location-list.vala
+++ b/src/baobab-location-list.vala
@@ -27,7 +27,8 @@ namespace Baobab {
 
         private List<Location> locations = null;
 
-        private LocationWidget.LocationAction? location_action;
+        public delegate void LocationAction (Location l);
+        private LocationAction? location_action;
 
         construct {
             monitor = VolumeMonitor.get ();
@@ -38,6 +39,7 @@ namespace Baobab {
             monitor.volume_removed.connect (volume_removed);
             monitor.volume_added.connect (volume_added);
 
+            set_selection_mode (Gtk.SelectionMode.NONE);
             set_separator_funcs (update_separator);
 
             populate ();
@@ -51,6 +53,13 @@ namespace Baobab {
             }
         }
 
+        public override void child_activated (Gtk.Widget? widget) {
+            if (location_action != null) {
+                var location_widget = widget as LocationWidget;
+                location_action (location_widget.location);
+            }
+        }
+
         void volume_changed (Volume volume) {
             update ();
         }
@@ -147,7 +156,7 @@ namespace Baobab {
             update ();
         }
 
-        public void set_action (owned LocationWidget.LocationAction? action) {
+        public void set_action (owned LocationAction? action) {
             location_action = (owned)action;
         }
 
@@ -155,7 +164,7 @@ namespace Baobab {
             this.foreach ((widget) => { widget.destroy (); });
 
             foreach (var location in locations) {
-                add (new LocationWidget (location, location_action));
+                add (new LocationWidget (location));
             }
 
             show_all ();
diff --git a/src/baobab-location-widget.vala b/src/baobab-location-widget.vala
index 8de9537..73d8720 100644
--- a/src/baobab-location-widget.vala
+++ b/src/baobab-location-widget.vala
@@ -24,21 +24,17 @@ namespace Baobab {
     public class LocationWidget : Gtk.Grid {
         private static Gtk.SizeGroup name_size_group = null;
         private static Gtk.SizeGroup usage_size_group = null;
-        private static Gtk.SizeGroup button_size_group = null;
 
         public Location? location { get; private set; }
 
-        public delegate void LocationAction (Location l);
-
         void ensure_size_groups () {
             if (name_size_group == null) {
                 name_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
                 usage_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
-                button_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
             }
         }
 
-        public LocationWidget (Location location_, LocationAction action) {
+        public LocationWidget (Location location_) {
             location = location_;
 
             orientation = Gtk.Orientation.HORIZONTAL;
@@ -97,13 +93,6 @@ namespace Baobab {
                 attach (usagebar, 2, 1, 1, 1);
             }
 
-            var button = new Gtk.Button.with_label (location.file != null ? _("Scan") : _("Mount and Scan"));
-            button_size_group.add_widget (button);
-            button.valign = Gtk.Align.CENTER;
-            attach (button, 3, 0, 1, 2);
-
-            button.clicked.connect(() => { action (location); });
-
             show_all ();
         }
     }



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