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

[Source]

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

Public Instance methods

[Source]

    # File lib/virt-p2v/ui/main.rb, line 69
69:     def active_page
70:         return @selected
71:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 69
69:     def active_page
70:         return @selected
71:     end

[Source]

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

[Source]

    # File lib/virt-p2v/ui/main.rb, line 57
57:     def active_page=(name)
58:         raise "Attempt to activate non-existent page #{name}" \
59:             unless @pages.has_key?(name)
60: 
61:         page = @pages[name]
62: 
63:         @page_vbox = self.get_object('page_vbox') unless defined? @page_vbox
64:         @page_vbox.remove(@selected) if defined? @selected
65:         @page_vbox.add(page)
66:         @selected = page
67:     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 53
53:     def main_loop
54:         Gtk.main_with_queue 100
55:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 53
53:     def main_loop
54:         Gtk.main_with_queue 100
55:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 73
73:     def quit
74:         Gtk.main_quit()
75:     end

[Source]

    # File lib/virt-p2v/ui/main.rb, line 73
73:     def quit
74:         Gtk.main_quit()
75:     end

[Source]

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

[Source]

    # File lib/virt-p2v/ui/main.rb, line 49
49:     def register_handler(signal, handler)
50:         @signal_handlers[signal] = handler
51:     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: 
43:         # Explicitly set a cursor
44:         # This doesn't seem to happen automatically when the client is started
45:         # from xinit, leaving the user with no visible cursor.
46:         main.window.cursor = Gdk::Cursor.new(Gdk::Cursor::Type::X_CURSOR)
47:     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: 
43:         # Explicitly set a cursor
44:         # This doesn't seem to happen automatically when the client is started
45:         # from xinit, leaving the user with no visible cursor.
46:         main.window.cursor = Gdk::Cursor.new(Gdk::Cursor::Type::X_CURSOR)
47:     end

[Validate]