[Libguestfs] [PATCH 42/61] p2v: move GTK definitions from main to gtk.rb

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


---
 p2v/client/lib/virt-p2v/ui/gtk.rb  | 52 +++++++++++++++++++++++++++++++
 p2v/client/lib/virt-p2v/ui/main.rb | 64 --------------------------------------
 2 files changed, 52 insertions(+), 64 deletions(-)

diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb b/p2v/client/lib/virt-p2v/ui/gtk.rb
index 501c9ad..3984b7f 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -1 +1,53 @@
 require('gtk2') if !(Kernel.const_defined?(:NOGUI) && NOGUI == true)
+
+if Kernel.const_defined?(:NOGUI) && NOGUI == true
+  module VirtP2V
+  module UI
+    class NeverMind
+      def method_missing(m, *args, &block)
+        self
+      end
+
+      def self.method_missing(m, *args, &block)
+        self
+      end
+
+      def eigen
+        class << self
+          self
+        end
+      end
+
+      def initialize(main = nil, name=nil, *args)
+        @name = name
+        @main = main
+      end
+    end
+  end
+  end
+
+  module Gtk
+    Builder = VirtP2V::UI::NeverMind
+    STATE_NORMAL = 0
+    SELECTION_SINGLE = 1
+    TreeRowReference = VirtP2V::UI::NeverMind
+
+    def Gtk.timeout_add(timeout, &block)
+      while true
+        sleep(timeout/1000.0)
+        block.call
+      end
+    end
+
+    def Gtk.main_quit
+      exit(0)
+    end
+  end
+
+  module Gdk
+    Color = VirtP2V::UI::NeverMind
+    Cursor = VirtP2V::UI::NeverMind
+    Cursor::Type = VirtP2V::UI::NeverMind
+    Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
+  end
+end
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb b/p2v/client/lib/virt-p2v/ui/main.rb
index e49be35..891fe99 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -17,70 +17,6 @@
 require 'virt-p2v/ui/gtk'
 require 'virt-p2v/gtk-queue'
 
-if Kernel.const_defined?(:NOGUI) && NOGUI == true
-  module VirtP2V
-  module UI
-    class NeverMind
-      def method_missing(m, *args, &block)
-        _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
-          self.__id__.to_s : _a}
-        puts "Never mind call '#{m} #{_args}'. ON #{@name ||
-          ("NeverMind:"+self.__id__.to_s)}"
-        self
-      end
-
-      def self.method_missing(m, *args, &block)
-        _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
-          self.__id__.to_s : _a}
-        #puts "Never mind class call '#{m} #{_args}'. ON #{@name || self.inspect}"
-        puts "Never mind call '#{m} #{_args}'. ON #{@name ||
-          ("NeverMind:"+self.__id__.to_s)}"
-        self
-      end
-
-      def eigen
-        class << self
-          self
-        end
-      end
-
-      def initialize(main = nil, name=nil, *args)
-        @name = name
-        @main = main
-        #puts "Hi, I'm #{@name || self.inspect}"
-      end
-    end
-  end
-  end
-
-  module Gtk
-    Builder = VirtP2V::UI::NeverMind
-    STATE_NORMAL = 0
-    SELECTION_SINGLE = 1
-    TreeRowReference = VirtP2V::UI::NeverMind
-
-    def Gtk.timeout_add(timeout, &block)
-      p "Gtk.timeout_add"
-      while true
-        sleep(timeout/1000.0)
-  #      p "trying to call block #{block.inspect}"
-        block.call
-      end
-    end
-
-    def Gtk.main_quit
-      exit(0)
-    end
-  end
-
-  module Gdk
-    Color = VirtP2V::UI::NeverMind
-    Cursor = VirtP2V::UI::NeverMind
-    Cursor::Type = VirtP2V::UI::NeverMind
-    Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
-  end
-end
-
 module VirtP2V
 module UI
 
-- 
1.8.3.1




More information about the Libguestfs mailing list