configure: Detect camlp4 and bail if not available.
[guestfs-browser.git] / main.ml
diff --git a/main.ml b/main.ml
index 9a72113..69ee4e1 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -20,8 +20,6 @@ open Printf
 
 open Utils
 
-module G = Guestfs
-
 (* Main. *)
 let () =
   let cli_request = Cmdline.command_line () in
@@ -31,23 +29,77 @@ let () =
    *)
   if verbose () then (
     debug "%s %s" Config.package Config.version;
-    let v = fst (Libvirt.get_version ()) in
-    debug "libvirt %d.%d.%d"
-      (v / 1_000_000) ((v / 1_000) mod 1_000) (v mod 1_000);
-    let g = G.create () in
-    let v = G.version g in
-    debug "libguestfs %Ld.%Ld.%Ld%s"
-      v.G.major v.G.minor v.G.release v.G.extra;
-    G.close g;
+    debug "libguestfs %s" (libguestfs_version_string ());
+    debug "libvirt %s" (libvirt_version_string ());
   );
 
-  let ds = Window.open_main_window () in
-  Slave.set_failure_hook (Window.failure ds);
-  Slave.set_busy_hook ds.Window.throbber_busy;
-  Slave.set_idle_hook ds.Window.throbber_idle;
+  (* Create the main window. *)
+  let w = new Window.window in
+
+  (* Wire up hooks that carry messages from the slave thread
+   * to the main thread.
+   *)
+  Slave.set_failure_hook w#failure;
+  Slave.set_busy_hook w#throbber_busy;
+  Slave.set_idle_hook w#throbber_idle;
+  Slave.set_status_hook w#set_statusbar;
+  Slave.set_progress_hook w#progress;
+
+  (* Wire up the loosely-coupled external components of the filetree.
+   * See the note about signals in {!Filetree.tree} documentation.
+   *)
+  let tree = w#tree in
+  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_file_properties
+            ~callback:(Op_file_properties.file_properties 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));
+
+  (* Connect menu entry signals to the functions that implement them. *)
+  ignore (w#connect_kvm_signal
+            ~callback:(w#connect_to (Some "qemu:///system")));
+  ignore (w#connect_xen_signal
+            ~callback:(w#connect_to (Some "xen:///")));
+  ignore (w#connect_none_signal
+            ~callback:(w#connect_to None));
+  ignore (w#connect_uri_signal
+            ~callback:(Menu_open_uri.open_uri_dialog w));
+  ignore (w#open_disk_signal
+            ~callback:(Menu_open_disk.open_disk_dialog w));
+  ignore (w#reopen_signal ~callback:w#reopen);
+  ignore (
+    w#inspection_signal
+      ~callback:(
+        fun () ->
+          match tree#oses with
+          | [] -> ()
+          | os :: _ ->
+              (* Note the menu entry only shows data for the first OS,
+                 (for multiboot). *)
+              Op_inspection_dialog.inspection_dialog tree os
+      )
+  );
+  ignore (w#about_signal ~callback:(Menu_about.open_about_dialog w));
 
   (* What did the user request on the command line? *)
-  Window.run_cli_request ds cli_request;
+  w#run_cli_request cli_request;
 
   (* Run the main display thread.  When this returns, the application
    * has been closed.