Prepare for first binary release.
[guestfs-browser.git] / filetree.ml
index ecdba77..c4f62ab 100644 (file)
@@ -30,7 +30,7 @@ module G = Guestfs
 
 type t = Filetree_type.t
 
-let rec create ?status ~packing () =
+let rec create ~packing () =
   let view = GTree.view ~packing () in
   (*view#set_rules_hint true;*)
   (*view#selection#set_mode `MULTIPLE; -- add this later *)
@@ -86,7 +86,6 @@ let rec create ?status ~packing () =
     index_col = index_col;
     mode_col = mode_col; name_col = name_col; size_col = size_col;
     date_col = date_col; link_col = link_col;
-    status = status
   } in
 
   (* Open a context menu when a button is pressed. *)
@@ -139,7 +138,7 @@ and button_press ({ model = model; view = view } as t) ev =
           let row = model#get_iter path in
           let hdata = get_hdata t row in
           match hdata with
-          | _, (Loading | ErrorMessage _) -> None
+          | _, (Loading | ErrorMessage _ | Info _) -> None
           | _, (Top _ | Directory _ | File _) -> Some (path, hdata)
       ) paths in
 
@@ -177,7 +176,7 @@ and make_context_menu t paths =
     let item = factory#add_item "Directory information" in
     item#misc#set_sensitive false;
     let item = factory#add_item "Space used by directory" in
-    item#misc#set_sensitive false;
+    ignore (item#connect#activate ~callback:(disk_usage t path));
     ignore (factory#add_separator ());
     let item = factory#add_item "Download ..." in
     item#misc#set_sensitive false;
@@ -412,7 +411,7 @@ and expand_row ({ model = model; hash = hash } as t) row _ =
   | _, File _ | IsLeaf, _ -> assert false
 
   (* Node should not exist in the tree. *)
-  | NodeNotStarted, (Loading | ErrorMessage _) -> assert false
+  | NodeNotStarted, (Loading | ErrorMessage _ | Info _) -> assert false
 
 (* This is the callback when the slave has read the directory for us. *)
 and when_read_directory ({ model = model } as t) path entries =
@@ -437,13 +436,14 @@ and when_read_directory ({ model = model } as t) path entries =
       model#set ~row ~column:t.link_col (markup_of_link link)
   ) entries;
 
-  (* Remove the placeholder entry.  NB. Must be done AFTER adding
-   * the other entries, or else Gtk will unexpand the row.
+  (* Remove the placeholder "Loading" entry.  NB. Must be done AFTER
+   * adding the other entries, or else Gtk will unexpand the row.
    *)
   (try
-     let placeholder = model#iter_children ~nth:0 (Some row) in
-     ignore (model#remove placeholder)
-   with Invalid_argument _ -> ()
+     let hdata = IsLeaf, Loading in
+     let row = find_child_node_by_hdata t row hdata in
+     ignore (model#remove row)
+   with Invalid_argument _ | Not_found -> ()
   );
 
   (* The original directory entry has now been loaded, so
@@ -473,6 +473,3 @@ and when_read_directory_fail ({ model = model } as t) path exn =
   | exn ->
       (* unexpected exception: re-raise it *)
       raise exn
-
-let set_status_fn t status =
-  t.status <- Some status