X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=main.ml;h=82e4603fc2f91a142cf9ba0faee04f2e1017993e;hb=3b2348f5f4b770e3e7f886d851eeadc59bbd2357;hp=a823aa582e45bc52b676edb31dc7c4ff36b9371c;hpb=bbfe03c47f1d7f03c3e6c0cab9e4f500f588c80a;p=guestfs-browser.git diff --git a/main.ml b/main.ml index a823aa5..82e4603 100644 --- a/main.ml +++ b/main.ml @@ -16,68 +16,32 @@ * 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 () = + let cli_request = Cmdline.command_line () in - (* 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); + Slave.set_status_hook (Window.set_statusbar ws); + Slave.set_progress_hook (Window.progress 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.