Add Guest -> Operating system information menu item.
[guestfs-browser.git] / filetree.ml
index c224a8d..7217c4e 100644 (file)
@@ -500,6 +500,34 @@ object (self)
     hdata.state <- IsNode;
     self#set_visited row
 
+  (* Return os(es) in the tree, if any.  The root directory of the
+   * tree looks like this:
+   *
+   *  \ Top (OS ...)   # usually only one, but there can be zero or > 1
+   *  \ Top (OS ...)
+   *  \ Top (Volume ...)
+   *  \ TopWinReg
+   *  \ TopWinReg
+   *
+   * This returns only the Top (OS ...) entries.  See also #add_top_level_os
+   * method.
+   *)
+  method oses =
+    match model#get_iter_first with
+    | None -> []
+    | Some row ->
+        let rec loop acc =
+          let acc =
+            match (self#get_hdata row).content with
+            | Top (OS os) -> os :: acc
+            | _ -> acc in
+          if model#iter_next row then
+            loop acc
+          else
+            List.rev acc
+        in
+        loop []
+
   (* Signals. *)
   method clear_tree : callback:(unit -> unit) -> GtkSignal.id =
     clear_tree#connect ~after
@@ -629,7 +657,7 @@ object (self)
                 ~callback:(fun () -> op_download_dir_find0#call path));
 
     and add_top_os_items os path =
-      let item = factory#add_item "Operating system information" in
+      let item = factory#add_item "Operating system information ..." in
       ignore (item#connect#activate
                 ~callback:(fun () -> op_inspection_dialog#call os));
       ignore (factory#add_separator ());