Class VirtP2V::UI::Main
In: lib/virt-p2v/ui/main.rb
lib/virt-p2v/ui/main.rb
Parent: Object

Methods

Public Class methods

[Source]

     # File lib/virt-p2v/ui/main.rb, line 74
 74:     def initialize
 75:         @builder = Gtk::Builder.new()
 76: 
 77:         # Find the UI definition in $LOAD_PATH
 78:         i = $LOAD_PATH.index { |path|
 79:             File.exists?(path + '/virt-p2v/ui/p2v.ui')
 80:         }
 81:         @builder.add_from_file($LOAD_PATH[i] + '/virt-p2v/ui/p2v.ui')
 82: 
 83:         @signal_handlers = {}
 84:         self.register_handler('gtk_main_quit', method(:quit))
 85: 
 86:         # Configure the Wizard page frame
 87:         # Can't change these colours from glade for some reason
 88:         self.get_object('title_background').
 89:            modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse('#86ABD9'))
 90:         self.get_object('page_frame').
 91:            modify_fg(Gtk::STATE_NORMAL, Gdk::Color.parse('#86ABD9'))
 92: 
 93:         # Load all pages from glade
 94:         @pages = {}
 95:         [ 'network_win', 'server_win',
 96:           'conversion_win', 'success_win' ].each { |name|
 97:             page = self.get_object(name)
 98: 
 99:             child = page.children[0]
100:             page.remove(child)
101:             @pages[name] = child
102:         }
103: 
104:         # Set a default first page
105:         self.active_page = 'network_win'
106:     end

[Source]

     # File lib/virt-p2v/ui/main.rb, line 74
 74:     def initialize
 75:         @builder = Gtk::Builder.new()
 76: 
 77:         # Find the UI definition in $LOAD_PATH
 78:         i = $LOAD_PATH.index { |path|
 79:             File.exists?(path + '/virt-p2v/ui/p2v.ui')
 80:         }
 81:         @builder.add_from_file($LOAD_PATH[i] + '/virt-p2v/ui/p2v.ui')
 82: 
 83:         @signal_handlers = {}
 84:         self.register_handler('gtk_main_quit', method(:quit))
 85: 
 86:         # Configure the Wizard page frame
 87:         # Can't change these colours from glade for some reason
 88:         self.get_object('title_background').
 89:            modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse('#86ABD9'))
 90:         self.get_object('page_frame').
 91:            modify_fg(Gtk::STATE_NORMAL, Gdk::Color.parse('#86ABD9'))
 92: 
 93:         # Load all pages from glade
 94:         @pages = {}
 95:         [ 'network_win', 'server_win',
 96:           'conversion_win', 'success_win' ].each { |name|
 97:             page = self.get_object(name)
 98: 
 99:             child = page.children[0]
100:             page.remove(child)
101:             @pages[name] = child
102:         }
103: 
104:         # Set a default first page
105:         self.active_page = 'network_win'
106:     end

Public Instance methods

[Source]

    # File lib/virt-p2v/ui/main.rb, line 64
64:     def active_page
65:         return @selected
66:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 64
64:     def active_page
65:         return @selected
66:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 52
52:     def active_page=(name)
53:         raise "Attempt to activate non-existent page #{name}" \
54:             unless @pages.has_key?(name)
55: 
56:         page = @pages[name]
57: 
58:         @page_vbox = self.get_object('page_vbox') unless defined? @page_vbox
59:         @page_vbox.remove(@selected) if defined? @selected
60:         @page_vbox.add(page)
61:         @selected = page
62:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 52
52:     def active_page=(name)
53:         raise "Attempt to activate non-existent page #{name}" \
54:             unless @pages.has_key?(name)
55: 
56:         page = @pages[name]
57: 
58:         @page_vbox = self.get_object('page_vbox') unless defined? @page_vbox
59:         @page_vbox.remove(@selected) if defined? @selected
60:         @page_vbox.add(page)
61:         @selected = page
62:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 24
24:     def get_object(name)
25:         o = @builder.get_object(name)
26:         raise "Object #{name} not found in ui" unless o != nil
27: 
28:         return o
29:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 24
24:     def get_object(name)
25:         o = @builder.get_object(name)
26:         raise "Object #{name} not found in ui" unless o != nil
27: 
28:         return o
29:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 48
48:     def main_loop
49:         Gtk.main_with_queue 100
50:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 48
48:     def main_loop
49:         Gtk.main_with_queue 100
50:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 68
68:     def quit
69:         Gtk.main_quit()
70:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 68
68:     def quit
69:         Gtk.main_quit()
70:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 44
44:     def register_handler(signal, handler)
45:         @signal_handlers[signal] = handler
46:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 44
44:     def register_handler(signal, handler)
45:         @signal_handlers[signal] = handler
46:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 31
31:     def show
32:         @builder.connect_signals { |signal|
33:             raise "No hander for signal #{signal}" \
34:                 unless @signal_handlers.has_key?(signal)
35: 
36:             @signal_handlers[signal]
37:         }
38: 
39:         # Display the main window
40:         main = self.get_object('main_window')
41:         main.show_all()
42:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 31
31:     def show
32:         @builder.connect_signals { |signal|
33:             raise "No hander for signal #{signal}" \
34:                 unless @signal_handlers.has_key?(signal)
35: 
36:             @signal_handlers[signal]
37:         }
38: 
39:         # Display the main window
40:         main = self.get_object('main_window')
41:         main.show_all()
42:     end

[Validate]