* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
-open Utils
-
-(* Display state. *)
-type display_state = {
- window : GWindow.window;
- throbber_busy : unit -> unit;
- throbber_idle : unit -> unit;
-}
-
-let open_main_window () =
- let title = "Guest Filesystem Browser" in
- let window = GWindow.window ~width:800 ~height:600 ~title () in
- let vbox = GPack.vbox ~packing:window#add () in
-
- (* Do the menus. *)
- let menubar = GMenu.menu_bar ~packing:vbox#pack () in
- let factory = new GMenu.factory menubar in
- let accel_group = factory#accel_group in
- let connect_menu = factory#add_submenu "_Connect" in
-
- let factory = new GMenu.factory connect_menu ~accel_group in
- let quit_item = factory#add_item "E_xit" ~key:GdkKeysyms._Q in
-
- (* Quit. *)
- let quit _ = GMain.quit (); false in
- ignore (window#connect#destroy ~callback:GMain.quit);
- ignore (window#event#connect#delete ~callback:quit);
- ignore (quit_item#connect#activate
- ~callback:(fun () -> ignore (quit ()); ()));
+open Printf
- (* Top status area. *)
- let hbox = GPack.hbox ~border_width:4 ~packing:vbox#pack () in
- ignore (GMisc.label ~text:"Guest: " ~packing:hbox#pack ());
-
- (* Throbber, http://faq.pygtk.org/index.py?req=show&file=faq23.037.htp *)
- let static = Throbber.static () in
- (*let animation = Throbber.animation () in*)
- let throbber =
- GMisc.image ~pixbuf:static ~packing:(hbox#pack ~from:`END) () in
- let throbber_busy () =
- (*throbber#set_pixbuf animation*)
- (* Workaround because no binding for GdkPixbufAnimation: *)
- let file = Filename.dirname Sys.argv.(0) // "Throbber.gif" in
- throbber#set_file file
- and throbber_idle () =
- throbber#set_pixbuf static
- in
+open Utils
- window#show ();
- window#add_accel_group accel_group;
+(* Main. *)
+let () =
+ (* XXX command line *)
+ Utils.set_verbose_flag ();
- (* display_state which is threaded through all the other callbacks,
- * allowing callbacks to update the window.
+ (* If we're in verbose mode, print some debug information which
+ * could be useful in bug reports.
*)
- { window = window;
- throbber_busy = throbber_busy; throbber_idle = throbber_idle }
-
-let () =
- let ds = open_main_window () in
- Slave.set_failure_hook (failure ds);
- Slave.set_busy_hook ds.throbber_busy;
- Slave.set_idle_hook ds.throbber_idle;
+ if verbose () then (
+ debug "%s %s" Config.package Config.version;
+ debug "libguestfs %s" (libguestfs_version_string ());
+ debug "libvirt %s" (libvirt_version_string ());
+ );
+
+ let ws = Window.open_main_window () in
+ Slave.set_failure_hook (Window.failure ws);
+ Slave.set_busy_hook (Window.throbber_busy ws);
+ Slave.set_idle_hook (Window.throbber_idle ws);
+
+ (* What did the user request on the command line? *)
+ (*Window.run_cli_request ws cli_request;*)
(* Run the main display thread. When this returns, the application
* has been closed.