---
p2v/client/lib/virt-p2v/ui/main.rb | 46 +++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 6 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb b/p2v/client/lib/virt-p2v/ui/main.rb
index f65ff15..ccd11b1 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -30,8 +30,9 @@ module UI
self
end
- def initialize(name=nil, *args)
+ def initialize(main = nil, name=nil, *args)
@name = name
+ @main = main
puts "Hi, I'm #{@name || self.inspect}"
end
end
@@ -169,21 +170,53 @@ class NewMain < Main
puts "GET_OBJ #{name}"
@gui_objects ||= {}
@gui_objects[name] ||= if name == "network_device_list" then
- n = NeverMind.new name
+ n = NeverMind.new self, name
n.class.send(:define_method, :append) do |*args|
@items ||= []
@items << []
self
end
+ n.class.send(:define_method, :_items) do
+ #p @items
+ @items
+ end
n.class.send(:define_method, :"[]=") do |idx, item|
- p "called []= on #{name} with #{args}"
+ #p "called []= on #{name} with #{args}"
@items.last[idx] = item
- p @items
+ #p @items
+ self
+ end
+ n
+ elsif name == "network_device_list_view"
+ n = NeverMind.new self, name
+ n.class.send(:define_method, :selection) do
self
end
+ n.class.send(:define_method, :selected) do
+ # TODO: this needs a proper selection
+ # now it's only for a testing purpouse
+ # but later we need to reflect reality
+ # and not blindly return first device
+ nejm = @main.get_object("network_device_list")._items.first
+ p nejm
+ end
+ n
+ elsif ["server_hostname", "server_username",
"server_password",
+ "convert_name", "convert_cpus",
"convert_memory"].any?{|n| n==name}
+ # N.B. some of these are set by user
+ n = NeverMind.new self, name
+ n.class.send(:define_method, :text) do
+# p "called text on #{name}"
+ @text || ""
+ end
+ n.class.send(:define_method, :"text=") do |str|
+ @text = str
+ p "called text= #{str} on #{name}"
+ end
+# p n
n
else
- NeverMind.new name
+ NeverMind.new self, name
end
@gui_objects[name]
@@ -195,6 +228,7 @@ class NewMain < Main
# as would user do' based on parameters passed
# through kernel command line
puts "this is the main loop"
+ @signal_handlers["network_button_clicked"].call
end
def register_handler(signal, handler)
@@ -204,7 +238,7 @@ class NewMain < Main
def initialize dry=nil
super() unless dry
- @builder = NeverMind.new
+ @builder = NeverMind.new self
end
end
--
1.8.3.1