[baobab/reroot-view: 3/14] Report the progress while scanning



commit 0db84314f583675b57e53cc0d09b2991a880f5ea
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Jun 18 19:58:54 2020 +0200

    Report the progress while scanning

 data/ui/baobab-main-window.ui |  5 +++++
 src/baobab-window.vala        | 13 +++++++++++++
 2 files changed, 18 insertions(+)
---
diff --git a/data/ui/baobab-main-window.ui b/data/ui/baobab-main-window.ui
index 9a348f6..c6627c0 100644
--- a/data/ui/baobab-main-window.ui
+++ b/data/ui/baobab-main-window.ui
@@ -231,6 +231,11 @@
                       <property name="label">Scanning…</property>
                     </object>
                   </child>
+                  <child>
+                    <object class="GtkLabel" id="scanning_progress_label">
+                      <property name="visible">True</property>
+                    </object>
+                  </child>
                 </object>
               </child>
               <child>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 7a6666b..1a672a8 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -124,6 +124,8 @@ namespace Baobab {
         [GtkChild]
         private LocationList location_list;
         [GtkChild]
+        private Gtk.Label scanning_progress_label;
+        [GtkChild]
         private FolderDisplay folder_display;
         [GtkChild]
         private Gtk.TreeView treeview;
@@ -150,6 +152,7 @@ namespace Baobab {
 
         private Location? active_location = null;
         private ulong scan_completed_handler = 0;
+        private uint scanning_progress_id = 0;
 
         static Gdk.Cursor busy_cursor;
 
@@ -612,6 +615,11 @@ namespace Baobab {
                 scan_completed_handler = 0;
             }
 
+            if (scanning_progress_id > 0) {
+                Source.remove (scanning_progress_id);
+                scanning_progress_id = 0;
+            }
+
             try {
                 scanner.finish();
             } catch (IOError.CANCELLED e) {
@@ -668,6 +676,11 @@ namespace Baobab {
             clear_message ();
             set_ui_state (scanning_page, true);
 
+            scanning_progress_id = Timeout.add (100, () => {
+                scanning_progress_label.label = format_size (scanner.total_size);
+                return Source.CONTINUE;
+            });
+
             scanner.scan (force);
         }
 


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