Version 0.0.1
[guestfs-browser.git] / main.ml
1 (* Guestfs Browser.
2  * Copyright (C) 2010 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 open Printf
20
21 open Utils
22
23 module G = Guestfs
24
25 (* Main. *)
26 let () =
27   let cli_request = Cmdline.command_line () in
28
29   (* If we're in verbose mode, print some debug information which
30    * could be useful in bug reports.
31    *)
32   if verbose () then (
33     debug "%s %s" Config.package Config.version;
34     let v = fst (Libvirt.get_version ()) in
35     debug "libvirt %d.%d.%d"
36       (v / 1_000_000) ((v / 1_000) mod 1_000) (v mod 1_000);
37     let g = G.create () in
38     let v = G.version g in
39     debug "libguestfs %Ld.%Ld.%Ld%s"
40       v.G.major v.G.minor v.G.release v.G.extra;
41     G.close g;
42   );
43
44   let ds = Window.open_main_window () in
45   Slave.set_failure_hook (Window.failure ds);
46   Slave.set_busy_hook ds.Window.throbber_busy;
47   Slave.set_idle_hook ds.Window.throbber_idle;
48
49   (* What did the user request on the command line? *)
50   Window.run_cli_request ds cli_request;
51
52   (* Run the main display thread.  When this returns, the application
53    * has been closed.
54    *)
55   GtkThread.main ();
56   Slave.exit_thread ()