[Libguestfs] [PATCH 10/61] p2v: fake append and assign for network_device_list

Maros Zatko mzatko at redhat.com
Wed Feb 12 14:30:22 UTC 2014


---
 p2v/client/lib/virt-p2v/ui/main.rb | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/p2v/client/lib/virt-p2v/ui/main.rb b/p2v/client/lib/virt-p2v/ui/main.rb
index 93b2663..f65ff15 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -167,14 +167,26 @@ class NewMain < Main
     # versions of gtk2 objects, very similar to what we'd
     # need to write tests
     puts "GET_OBJ #{name}"
-    if name == "network_win" then
+    @gui_objects ||= {}
+    @gui_objects[name] ||= if name == "network_device_list" then
       n = NeverMind.new name
-#      n.define_method : do
-#
-#      end
+      n.class.send(:define_method, :append) do |*args|
+        @items ||= []
+        @items << []
+        self
+      end
+      n.class.send(:define_method, :"[]=") do |idx, item|
+        p "called []= on #{name} with #{args}"
+        @items.last[idx] = item
+        p @items
+        self
+      end
+      n
     else
       NeverMind.new name
     end
+
+    @gui_objects[name]
   end
 
   def main_loop
-- 
1.8.3.1




More information about the Libguestfs mailing list