Add About dialog.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 29 Jul 2011 16:15:09 +0000 (17:15 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 29 Jul 2011 16:27:00 +0000 (17:27 +0100)
.depend
Makefile.am
TODO
main.ml
menu_about.ml [new file with mode: 0644]
menu_about.mli [new file with mode: 0644]
utils.ml
utils.mli
window.ml
window.mli

diff --git a/.depend b/.depend
index 94b28dd..f6277c8 100644 (file)
--- a/.depend
+++ b/.depend
@@ -13,8 +13,11 @@ filetree.cmx: utils.cmx slave_types.cmx slave.cmx filetree_markup.cmx deviceSet.
 filetree_markup.cmi: slave_types.cmi
 filetree_markup.cmo: utils.cmi slave_types.cmi filetree_markup.cmi
 filetree_markup.cmx: utils.cmx slave_types.cmx filetree_markup.cmi
-main.cmo: window.cmi utils.cmi slave.cmi op_view_file.cmi op_inspection_dialog.cmi op_file_information.cmi op_download_file.cmi op_download_dir_tarball.cmi op_download_dir_find0.cmi op_download_as_reg.cmi op_disk_usage.cmi op_copy_regvalue.cmi op_checksum_file.cmi menu_open_uri.cmi menu_open_disk.cmi config.cmi cmdline.cmi
-main.cmx: window.cmx utils.cmx slave.cmx op_view_file.cmx op_inspection_dialog.cmx op_file_information.cmx op_download_file.cmx op_download_dir_tarball.cmx op_download_dir_find0.cmx op_download_as_reg.cmx op_disk_usage.cmx op_copy_regvalue.cmx op_checksum_file.cmx menu_open_uri.cmx menu_open_disk.cmx config.cmx cmdline.cmx
+main.cmo: window.cmi utils.cmi slave.cmi op_view_file.cmi op_inspection_dialog.cmi op_file_information.cmi op_download_file.cmi op_download_dir_tarball.cmi op_download_dir_find0.cmi op_download_as_reg.cmi op_disk_usage.cmi op_copy_regvalue.cmi op_checksum_file.cmi menu_open_uri.cmi menu_open_disk.cmi menu_about.cmi config.cmi cmdline.cmi
+main.cmx: window.cmx utils.cmx slave.cmx op_view_file.cmx op_inspection_dialog.cmx op_file_information.cmx op_download_file.cmx op_download_dir_tarball.cmx op_download_dir_find0.cmx op_download_as_reg.cmx op_disk_usage.cmx op_copy_regvalue.cmx op_checksum_file.cmx menu_open_uri.cmx menu_open_disk.cmx menu_about.cmx config.cmx cmdline.cmx
+menu_about.cmi: window.cmi
+menu_about.cmo: utils.cmi config.cmi menu_about.cmi
+menu_about.cmx: utils.cmx config.cmx menu_about.cmi
 menu_open_disk.cmi: window.cmi
 menu_open_disk.cmo: utils.cmi menu_open_disk.cmi
 menu_open_disk.cmx: utils.cmx menu_open_disk.cmi
index 2dbe1ba..ac197c4 100644 (file)
@@ -47,6 +47,8 @@ SOURCES = \
        filetree_markup.mli \
        filetree_markup.ml \
        main.ml \
+       menu_about.mli \
+       menu_about.ml \
        menu_open_disk.mli \
        menu_open_disk.ml \
        menu_open_uri.mli \
@@ -110,6 +112,7 @@ OBJECTS = \
        op_view_file.cmo \
        menu_open_uri.cmo \
        menu_open_disk.cmo \
+       menu_about.cmo \
        window.cmo \
        main.cmo
 
diff --git a/TODO b/TODO
index d872f12..7431a7f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -18,6 +18,4 @@ The slave thread should not have to remount filesystems.
 If the mount points are the same as the previous command, it
 should cache them.
 
-About dialog
-
 Extended attributes, SELinux.
diff --git a/main.ml b/main.ml
index c6c60c5..f8a368d 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -94,6 +94,7 @@ let () =
               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? *)
   w#run_cli_request cli_request;
diff --git a/menu_about.ml b/menu_about.ml
new file mode 100644 (file)
index 0000000..49819a2
--- /dev/null
@@ -0,0 +1,67 @@
+(* Guestfs Browser.
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Utils
+
+open Printf
+
+let license =
+  "\
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."
+
+let authors = [
+  "Richard W.M. Jones"
+]
+
+let logo =
+  let rec loop = function
+    | [] -> None
+    | filename :: rest ->
+        try Some (GdkPixbuf.from_file_at_size ~width:100 ~height:100 filename)
+        with _ -> loop rest
+  in
+  loop [Config.icondir ^ "/guestfs-browser.svg";
+        "guestfs-browser.svg"]
+
+let open_about_dialog w () =
+  let d = GWindow.about_dialog
+    ~name:"Guest filesystem browser"
+    ~version:Config.version
+    ?logo
+    ~authors
+    ~copyright:(utf8_copyright ^ " 2010-2011 Red Hat Inc.")
+    ~license
+    ~website:"http://people.redhat.com/~rjones/guestfs-browser/"
+    ~website_label:"Visit the guestfs-browser website"
+    ~modal:true
+    () in
+
+  ignore (d#run ());
+  d#destroy ()
diff --git a/menu_about.mli b/menu_about.mli
new file mode 100644 (file)
index 0000000..bd9ba22
--- /dev/null
@@ -0,0 +1,21 @@
+(* Guestfs Browser.
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(** Help -> About dialog. *)
+
+val open_about_dialog : Window.window -> unit -> unit
index 3afcf99..4ec1531 100644 (file)
--- a/utils.ml
+++ b/utils.ml
@@ -62,6 +62,7 @@ let connect_uri = ref None
 let set_connect_uri conn = connect_uri := conn
 let connect_uri () = !connect_uri
 
+let utf8_copyright = "\194\169"
 let utf8_rarrow = "\xe2\x86\x92"
 
 let pretty_string_of_exn =
index ca792ca..759dde1 100644 (file)
--- a/utils.mli
+++ b/utils.mli
@@ -66,6 +66,7 @@ val pretty_string_of_exn : exn -> string * string
       To get raw exception string, use {!Printexc.to_string} from the
       standard library. *)
 
+val utf8_copyright : string (** UTF-8 copyright symbol *)
 val utf8_rarrow : string (** UTF-8 RIGHTWARDS ARROW *)
 
 val human_size : int64 -> string
index ac6c34c..baa63b2 100644 (file)
--- a/window.ml
+++ b/window.ml
@@ -39,6 +39,11 @@ type guest_menu = {
   guest_inspection_item : GMenu.menu_item;
 }
 
+type help_menu = {
+  help_menu : GMenu.menu;
+  about_item : GMenu.menu_item;
+}
+
 class window =
   (* Window. *)
   let title = "Guest Filesystem Browser" in
@@ -74,6 +79,12 @@ class window =
     let inspection = factory#add_item "Operating system information ..." in
     { guest_menu = menu; guest_inspection_item = inspection } in
 
+  let help_menu =
+    let menu = factory#add_submenu "_Help" in
+    let factory = new GMenu.factory menu ~accel_group in
+    let about = factory#add_item "About guest filesystem browser ..." in
+    { help_menu = menu; about_item = about } in
+
   (* Top toolbar. *)
   let hbox =
     let hbox = GPack.hbox ~border_width:4 ~packing:vbox#pack () in
@@ -121,6 +132,7 @@ class window =
   let open_disk_signal = new GUtil.signal () in
   let reopen_signal = new GUtil.signal () in
   let inspection_signal = new GUtil.signal () in
+  let about_signal = new GUtil.signal () in
 
 object (self)
   inherit GUtil.ml_signals [connect_kvm_signal#disconnect;
@@ -129,7 +141,8 @@ object (self)
                             connect_uri_signal#disconnect;
                             open_disk_signal#disconnect;
                             reopen_signal#disconnect;
-                            inspection_signal#disconnect]
+                            inspection_signal#disconnect;
+                            about_signal#disconnect]
 
   method connect_kvm_signal = connect_kvm_signal#connect ~after
   method connect_xen_signal = connect_xen_signal#connect ~after
@@ -138,6 +151,7 @@ object (self)
   method open_disk_signal = open_disk_signal#connect ~after
   method reopen_signal = reopen_signal#connect ~after
   method inspection_signal = inspection_signal#connect ~after
+  method about_signal = about_signal#connect ~after
 
   initializer
     ignore (statusbar_context#push title);
@@ -168,6 +182,8 @@ object (self)
               ~callback:reopen_signal#call);
     ignore (guest_menu.guest_inspection_item#connect#activate
               ~callback:inspection_signal#call);
+    ignore (help_menu.about_item#connect#activate
+              ~callback:about_signal#call);
 
     (* VM combo box when changed by the user.
      * The refresh button acts like changing the VM combo too.
index 530acbc..670b94a 100644 (file)
@@ -32,6 +32,7 @@ object ('a)
   method open_disk_signal : callback:(unit -> unit) -> GtkSignal.id
   method reopen_signal : callback:(unit -> unit) -> GtkSignal.id
   method inspection_signal : callback:(unit -> unit) -> GtkSignal.id
+  method about_signal : callback:(unit -> unit) -> GtkSignal.id
 
   method failure : exn -> unit
     (** This is the global error handling function.  It is invoked in