[gnome-boxes] util: Add class for reporting & tracking progress



commit 47dcb6baa877d12819c7da7914f32bbdbecf63d5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Dec 17 04:51:25 2012 +0200

    util: Add class for reporting & tracking progress
    
    Add class for reporting and tracking of progress of async activities.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690321

 src/util.vala |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/util.vala b/src/util.vala
index f98e3ae..e16c1ef 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -296,6 +296,23 @@ namespace Boxes {
         }
     }
 
+    public class ActivityProgress : GLib.Object {
+        public double progress { get; set; }
+        public string info { get; set; default = ""; }
+
+        public ActivityProgress add_child_activity (double scale) {
+            var child_progress = new ActivityProgress ();
+            var last_child_progress = 0d;
+            child_progress.notify["progress"].connect (() => {
+                var child_progress_delta = child_progress.progress - last_child_progress;
+                this.progress += child_progress_delta * scale;
+                last_child_progress = child_progress.progress;
+            });
+
+            return child_progress;
+        }
+    }
+
     public bool is_set (string? str) {
         return str != null && str != "";
     }



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