Refactor code to add inspection dialog.
[guestfs-browser.git] / window.ml
index c9955df..2dd32cd 100644 (file)
--- a/window.ml
+++ b/window.ml
@@ -26,7 +26,7 @@ module G = Guestfs
 (* Main window state. *)
 type window_state = {
   window : GWindow.window;
-  view : Filetree.t;
+  view : Filetree.tree;
   vmcombo : GEdit.combo_box GEdit.text_combo;
   refresh_button : GButton.button;
   throbber : GMisc.image;
@@ -43,7 +43,7 @@ let set_statusbar ws msg =
 
 (* Clear the filetree. *)
 let clear_view ws =
-  Filetree.clear ws.view
+  ws.view#clear ()
 
 (* Callback from Connect -> ... menu items. *)
 let rec connect_to ws uri =
@@ -104,7 +104,7 @@ and when_opened_common ws name data =
       debug "root device %s contains %s %s %d.%d" root typ distro major minor;
   ) data.insp_oses;
 
-  Filetree.add ws.view name data
+  ws.view#add_os name data
 
 let throbber_busy ws () =
   (*throbber#set_pixbuf animation*)
@@ -278,9 +278,36 @@ and make_toolbar ~packing () =
   vmcombo, refresh_button, throbber, static
 
 and make_filetree ~packing () =
+  (* Create the filetree inside a scrolled window. *)
   let sw =
     GBin.scrolled_window ~packing ~hpolicy:`AUTOMATIC ~vpolicy:`ALWAYS () in
-  Filetree.create ~packing:sw#add ()
+  let tree = new Filetree.tree ~packing:sw#add () in
+
+  (* Wire up the loosely-coupled external components of the filetree.
+   * See the note about signals in {!Filetree.tree} documentation.
+   *)
+  ignore (tree#op_checksum_file
+            ~callback:(Op_checksum_file.checksum_file tree));
+  ignore (tree#op_copy_regvalue
+            ~callback:(Op_copy_regvalue.copy_regvalue tree));
+  ignore (tree#op_disk_usage
+            ~callback:(Op_disk_usage.disk_usage tree));
+  ignore (tree#op_download_as_reg
+            ~callback:(Op_download_as_reg.download_as_reg tree));
+  ignore (tree#op_download_dir_find0
+            ~callback:(Op_download_dir_find0.download_dir_find0 tree));
+  ignore (tree#op_download_dir_tarball
+            ~callback:(Op_download_dir_tarball.download_dir_tarball tree));
+  ignore (tree#op_download_file
+            ~callback:(Op_download_file.download_file tree));
+  ignore (tree#op_file_information
+            ~callback:(Op_file_information.file_information tree));
+  ignore (tree#op_inspection_dialog
+            ~callback:(Op_inspection_dialog.inspection_dialog tree));
+  ignore (tree#op_view_file
+            ~callback:(Op_view_file.view_file tree));
+
+  tree
 
 (* Do what the user asked on the command line. *)
 let rec run_cli_request ws = function