(* Virt resize UI. * 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. *) type file_menu = { quit_item : GMenu.menu_item; } type help_menu = { about_item : GMenu.menu_item; } type tabs = { source_tab : Source_tab.tab; destination_tab : Destination_tab.tab; partitions_tab : Partitions_tab.tab; logvols_tab : Logvols_tab.tab; } type buttons = { prev_button : GButton.button; next_button : GButton.button; go_button : GButton.button; exit_button : GButton.button; } class window = let title = "Resize a virtual machine - virt-resize-ui" in object (self) initializer (* Window. *) let window = GWindow.window ~width:700 ~height:700 ~title () in let vbox = GPack.vbox ~packing:window#add () in (* 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 file_menu = let menu = factory#add_submenu "_File" in let factory = new GMenu.factory menu ~accel_group in let quit = factory#add_item "E_xit" ~key:GdkKeysyms._Q in { quit_item = quit } 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 virt-resize-ui ..." in { about_item = about } in (* Tabbed notebook for main part of the display. *) let tabs = let nb = GPack.notebook ~packing:(vbox#pack ~expand:true ~fill:true) () in let src = Source_tab.tab () in let tab_label = (GMisc.label ~text:"Source" () :> GObj.widget) in ignore (nb#append_page ~tab_label (src :> GObj.widget)); let dest = Destination_tab.tab () in let tab_label = (GMisc.label ~text:"Destination" () :> GObj.widget) in ignore (nb#append_page ~tab_label (dest :> GObj.widget)); let parts = Partitions_tab.tab () in let tab_label = (GMisc.label ~text:"Resize partitions" () :> GObj.widget) in ignore (nb#append_page ~tab_label (parts :> GObj.widget)); let lvs = Logvols_tab.tab () in let tab_label = (GMisc.label ~text:"Expand logical volumes" () :> GObj.widget) in ignore (nb#append_page ~tab_label (lvs :> GObj.widget)); { source_tab = src; destination_tab = dest; partitions_tab = parts; logvols_tab = lvs } in (* Buttons. *) let buttons = let bbox = GPack.button_box `HORIZONTAL ~packing:vbox#pack () in bbox#set_border_width 8; let ex = GButton.button ~stock:`QUIT ~packing:bbox#pack () in ex#misc#set_sensitive true; let prev = GButton.button ~stock:`GO_BACK ~packing:bbox#pack () in prev#misc#set_sensitive false; let next = GButton.button ~stock:`GO_FORWARD ~packing:bbox#pack () in next#misc#set_sensitive true; let go = GButton.button ~stock:`APPLY ~packing:bbox#pack () in go#misc#set_sensitive false; { prev_button = prev; next_button = next; go_button = go; exit_button = ex } in ignore help_menu; ignore tabs; (* Quit button. *) let quit _ = GMain.quit (); false in ignore (window#connect#destroy ~callback:GMain.quit); ignore (window#event#connect#delete ~callback:quit); ignore (file_menu.quit_item#connect#activate ~callback:(fun () -> ignore (quit ()); ())); ignore (buttons.exit_button#connect#clicked ~callback:(fun () -> ignore (quit ()); ())); (* Accel_group. *) window#add_accel_group accel_group; window#show () end