Update HACKING document.
[guestfs-browser.git] / window.ml
index aac7380..6e720b7 100644 (file)
--- a/window.ml
+++ b/window.ml
@@ -19,6 +19,7 @@
 open Printf
 
 open Utils
+open Slave_types
 
 module G = Guestfs
 
@@ -59,7 +60,7 @@ and populate_vmcombo ws doms =
   let combo, (model, column) = ws.vmcombo in
   model#clear ();
   List.iter (
-    fun { Slave.dom_name = name } ->
+    fun { dom_name = name } ->
       let row = model#append () in
       model#set ~row ~column name
   ) doms
@@ -96,12 +97,12 @@ and when_opened_disk_images ws images data =
 and when_opened_common ws name data =
   (* Dump some of the inspection data in debug messages. *)
   List.iter (fun (dev, t) -> debug "filesystem: %s: %s" dev t)
-    data.Slave.insp_all_filesystems;
+    data.insp_all_filesystems;
   List.iter (
-    fun { Slave.insp_root = root; insp_type = typ; insp_distro = distro;
+    fun { insp_root = root; insp_type = typ; insp_distro = distro;
           insp_major_version = major; insp_minor_version = minor } ->
       debug "root device %s contains %s %s %d.%d" root typ distro major minor;
-  ) data.Slave.insp_oses;
+  ) data.insp_oses;
 
   Filetree.add ws.view name data
 
@@ -115,8 +116,16 @@ let throbber_idle ws () =
   ws.throbber#set_pixbuf ws.throbber_static
 
 let progress ws (position, total) =
-  ws.progress_bar#set_fraction
-    (Int64.to_float position /. Int64.to_float total)
+  if position = 0L && total = 1L then
+    ws.progress_bar#pulse ()
+  else (
+    let frac = Int64.to_float position /. Int64.to_float total in
+    if frac < 0. || frac > 1. then
+      eprintf "warning: progress bar out of range: %Ld / %Ld (%g)\n"
+        position total frac;
+    let frac = if frac < 0. then 0. else if frac > 1. then 1. else frac in
+    ws.progress_bar#set_fraction frac
+  )
 
 (* This is called in the main thread whenever a command fails in the
  * slave thread.  The command queue has been cleared before this is
@@ -293,7 +302,7 @@ and when_connected_cli_request ws guest doms =
     | d::ds when d = guest -> i
     | _::ds -> loop (i+1) ds
   in
-  let i = loop 0 (List.map (fun { Slave.dom_name = name } -> name) doms) in
+  let i = loop 0 (List.map (fun { dom_name = name } -> name) doms) in
 
   let combo, _ = ws.vmcombo in
   combo#set_active i