From c2c9d5bbc2ae5831a912ed5d33d04d43cad09660 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 28 Jul 2011 21:37:13 +0100 Subject: [PATCH] Use tabs for inspection dialog. --- op_inspection_dialog.ml | 61 +++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/op_inspection_dialog.ml b/op_inspection_dialog.ml index 2e84ded..2189e11 100644 --- a/op_inspection_dialog.ml +++ b/op_inspection_dialog.ml @@ -19,67 +19,69 @@ open Printf open Utils +open Slave_types module G = Guestfs let rec inspection_dialog tree os = debug "inspection dialog"; let title = "Inspection data" in - let d = GWindow.dialog ~title () in + let d = GWindow.dialog ~width:500 ~height:600 ~title () in + + let nb = GPack.notebook ~packing:d#vbox#add () in (* Fill in the basic information. *) - let packing : GObj.widget -> unit = d#vbox#add in - let vbox = frame ~label:"Basic information" ~packing () in + let vbox = tab "Basic information" nb in let tbl = GPack.table ~columns:4 ~rows:1 ~packing:vbox#add () in tbl#set_col_spacings 8; tbl#set_row_spacings 8; - wide tbl 0 "Product name: " os.Slave_types.insp_product_name; - wide tbl 1 "Hostname: " os.Slave_types.insp_hostname; + wide tbl 0 "Product name: " os.insp_product_name; + wide tbl 1 "Hostname: " os.insp_hostname; - simple tbl 2 0 "OS type: " os.Slave_types.insp_type; - simple tbl 3 0 "Distro: " os.Slave_types.insp_distro; + simple tbl 2 0 "OS type: " os.insp_type; + simple tbl 3 0 "Distro: " os.insp_distro; simple tbl 4 0 "Version: " (sprintf "%d.%d" - os.Slave_types.insp_major_version - os.Slave_types.insp_minor_version); - simple tbl 5 0 "Product variant: " os.Slave_types.insp_product_variant; + os.insp_major_version + os.insp_minor_version); + simple tbl 5 0 "Product variant: " os.insp_product_variant; - simple tbl 2 2 "Root: " os.Slave_types.insp_root; - simple tbl 3 2 "Arch: " os.Slave_types.insp_arch; - simple tbl 4 2 "Package mgr: " os.Slave_types.insp_package_management; - simple tbl 5 2 "Package fmt: " os.Slave_types.insp_package_format; + simple tbl 2 2 "Root: " os.insp_root; + simple tbl 3 2 "Arch: " os.insp_arch; + simple tbl 4 2 "Package mgr: " os.insp_package_management; + simple tbl 5 2 "Package fmt: " os.insp_package_format; - (match os.Slave_types.insp_windows_systemroot with + (match os.insp_windows_systemroot with | None -> () | Some systemroot -> simple tbl 6 0 "%systemroot%: " systemroot ); - (match os.Slave_types.insp_windows_current_control_set with + (match os.insp_windows_current_control_set with | None -> () | Some ccs -> simple tbl 6 2 "CurrentControlSet: " ccs ); (* Applications. *) - let vbox = frame ~label:"Applications" ~packing:d#vbox#add () in + let vbox = tab "Applications" nb in applications_view ~packing:vbox#add os; (* Mountpoints. *) - let vbox = frame ~label:"Mount points" ~packing:d#vbox#add () in + let vbox = tab "Mount points" nb in two_column_view ~title1:"Mount" ~title2:"Filesystem" - ~packing:vbox#add os.Slave_types.insp_mountpoints; + ~packing:vbox#add os.insp_mountpoints; (* Filesystems. *) - let vbox = frame ~label:"Filesystems" ~packing:d#vbox#add () in + let vbox = tab "Filesystems" nb in one_column_view ~title:"Filesystem" ~packing:vbox#add - (Array.to_list os.Slave_types.insp_filesystems); + (Array.to_list os.insp_filesystems); (* Drive mappings. *) - (match os.Slave_types.insp_drive_mappings with + (match os.insp_drive_mappings with | [] -> () | mappings -> - let vbox = frame ~label:"Drives" ~packing:d#vbox#add () in + let vbox = tab "Drive letters" nb in two_column_view ~title1:"Drive letter" ~title2:"Filesystem" ~packing:vbox#add mappings ); @@ -108,9 +110,11 @@ let rec inspection_dialog tree os = d#show () (* Helper functions. *) -and frame ?label ?packing () = - let frame = GBin.frame ?label ?packing () in - GPack.vbox ~border_width:8 ~packing:frame#add () +and tab text nb = + let vbox = GPack.vbox ~border_width:8 () in + let tab_label = (GMisc.label ~text () :> GObj.widget) in + ignore (nb#append_page ~tab_label (vbox :> GObj.widget)); + vbox and simple tbl top left label text = let markup = sprintf "%s" (markup_escape text) in @@ -127,6 +131,7 @@ and wide tbl top label text = ~markup ~packing:(tbl#attach ~top ~left:1 ~right:4) ()); and one_column_view ~title ?packing data = + let data = List.sort compare data in let model, c1 = GTree.store_of_list Gobject.Data.string data in let sw = @@ -141,6 +146,8 @@ and one_column_view ~title ?packing data = ignore (view#append_column vc) and two_column_view ~title1 ~title2 ?packing data = + let data = List.sort compare data in + let cols = new GTree.column_list in let c1 = cols#add Gobject.Data.string in let c2 = cols#add Gobject.Data.string in @@ -179,7 +186,7 @@ and applications_view ?packing os = let sw = GBin.scrolled_window ?packing ~hpolicy:`AUTOMATIC ~vpolicy:`ALWAYS () in - let view = GTree.view ~model ~height:150 ~packing:sw#add () in + let view = GTree.view ~model ~packing:sw#add () in view#selection#set_mode `NONE; let renderer = GTree.cell_renderer_text [], ["text", name_col] in -- 1.8.3.1