[baobab/wip/grid-layout: 4/8] Add to the volume list "Scan folder" and "Scan remote folder"



commit c07fa0fbc6fef464589135d16e1e10bd1b4ccc99
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Wed Apr 11 15:54:00 2012 +0200

    Add to the volume list "Scan folder" and "Scan remote folder"

 src/baobab-location-widget.vala |   50 ++++++++++++++++++++++++++++++++++++++-
 src/baobab-window.vala          |   10 +++++++-
 2 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/src/baobab-location-widget.vala b/src/baobab-location-widget.vala
index fc527de..d669077 100644
--- a/src/baobab-location-widget.vala
+++ b/src/baobab-location-widget.vala
@@ -101,9 +101,57 @@ namespace Baobab {
             button_size_group.add_widget (button);
             add (button);
 
-            button.clicked.connect(() => { action (location); });
+            button.clicked.connect (() => { action (location); });
 
             show_all ();
         }
     }
+
+    public class ScanFolderWidget : BaseLocationWidget  {
+
+        public ScanFolderWidget (BaseLocationWidget.ActionOnClick action) {
+            base ();
+
+            var icon_theme = Gtk.IconTheme.get_default ();
+            var icon_info = icon_theme.lookup_icon ("folder", 64, 0);
+
+            try {
+                var pixbuf = icon_info.load_icon ();
+                var image = new Gtk.Image.from_pixbuf (pixbuf);
+                add (image);
+            } catch (Error e) {
+                warning ("Failed to load icon: %s", e.message);
+            }
+
+            var button = new Gtk.Button.with_label (_("Scan folder"));
+            button.valign = Gtk.Align.CENTER;
+            add (button);
+
+            button.clicked.connect (() => { action (); });
+        }
+    }
+
+    public class ScanRemoteFolderWidget : BaseLocationWidget  {
+
+        public ScanRemoteFolderWidget (BaseLocationWidget.ActionOnClick action) {
+            base ();
+
+            var icon_theme = Gtk.IconTheme.get_default ();
+            var icon_info = icon_theme.lookup_icon ("folder-remote", 64, 0);
+
+            try {
+                var pixbuf = icon_info.load_icon ();
+                var image = new Gtk.Image.from_pixbuf (pixbuf);
+                add (image);
+            } catch (Error e) {
+                warning ("Failed to load icon: %s", e.message);
+            }
+
+            var button = new Gtk.Button.with_label (_("Scan network folder"));
+            button.valign = Gtk.Align.CENTER;
+            add (button);
+
+            button.clicked.connect (() => { action (); });
+        }
+    }
 }
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index dae5689..5f60c14 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -341,7 +341,7 @@ namespace Baobab {
                     });
                 } else {
                     loc_widget = new LocationWidget (location, (location_) => {
-                        location_.mount_volume.begin ((location__, res) => {
+                        location_.mount_volume.begin ((obj, res) => {
                             try {
                                 location_.mount_volume.end (res);
                                 scan_directory (File.new_for_path (location_.mount_point), ScanFlags.EXCLUDE_MOUNTS);
@@ -355,6 +355,14 @@ namespace Baobab {
                 location_view.add (loc_widget);
             }
 
+            location_view.add (new ScanFolderWidget ((location_) => {
+                on_scan_folder_activate ();
+            }));
+
+            location_view.add (new ScanRemoteFolderWidget ((location_) => {
+                on_scan_remote_activate ();
+            }));
+
             location_view.show_all ();
         }
 



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