Hi,

I would like to use some classes in the converted ruby code but I
have problems with function lookup.

I have figured out how to call functions (e.g. ArrangeButtons
from include/partitioning/ep-lib.rb in my class method by using
"module_function :ArrangeButtons" in ep-lib.rb. The problem now
is that the method deep_copy cannot be found inside
ArrangeButtons.

It works if I use "include PartitioningEpLibInclude" inside my
class but I don't like to extend the classes with lots of general
utility functions.

So what's the correct way here?

Attached is a patch.

The error message is:

Client call failed with undefined method `deep_copy' for
Yast::PartitioningEpLibInclude:Module and backtrace
["/usr/share/YaST2/include/partitioning/ep-lib.rb:503:in
`ArrangeButtons'",
"/usr/share/YaST2/include/partitioning/ep-all.rb:183:in
`create'", ...

ciao Arvin

diff --git a/src/include/partitioning/ep-all.rb b/src/include/partitioning/ep-all.rb
index 1fd3f3b..176bda4 100644
--- a/src/include/partitioning/ep-all.rb
+++ b/src/include/partitioning/ep-all.rb
@@ -32,7 +32,12 @@ module Yast
       Yast.import "PackageSystem"
     end
 
-    def CreateAllPanel(user_data)
+
+    class AllPanel < TreePanelClass::Panel
+
+      # include PartitioningEpLibInclude # don't like this
+
+    def create(user_data)
       user_data = deep_copy(user_data)
       _IsAvailable = lambda do |client|
         #in the installed system, we don't care if the client isn't there
@@ -175,7 +180,8 @@ module Yast
               table_header,
               table_contents
             ),
-            ArrangeButtons(buttons)
+            PartitioningEpLibInclude::ArrangeButtons(buttons)
+            # ArrangeButtons(buttons)
           )
         )
       )
@@ -211,7 +217,7 @@ module Yast
     end
 
 
-    def HandleAllPanel(user_data, event)
+    def handle(user_data, event)
       user_data = deep_copy(user_data)
       event = deep_copy(event)
       _CheckAndInstallPackages = lambda do |pkgs|
@@ -351,5 +357,8 @@ module Yast
 
       nil
     end
+
+    end
+
   end
 end
diff --git a/src/include/partitioning/ep-lib.rb b/src/include/partitioning/ep-lib.rb
index 66c2b3a..39a4407 100644
--- a/src/include/partitioning/ep-lib.rb
+++ b/src/include/partitioning/ep-lib.rb
@@ -550,6 +550,9 @@ module Yast
       deep_copy(ret)
     end
 
+    module_function :ArrangeButtons
+
+
     def ChangeWidgetIfExists(wid, property, value)
       value = deep_copy(value)
       UI.ChangeWidget(Id(wid), property, value) if UI.WidgetExists(Id(wid))
diff --git a/src/include/partitioning/ep-main.rb b/src/include/partitioning/ep-main.rb
index 57c7d72..752ea80 100644
--- a/src/include/partitioning/ep-main.rb
+++ b/src/include/partitioning/ep-main.rb
@@ -113,10 +113,7 @@ module Yast
       # TODO: somehow use AlwaysHideDisk
 
       data = {
-        :all         => {
-          :create => fun_ref(method(:CreateAllPanel), "void (any)"),
-          :handle => fun_ref(method(:HandleAllPanel), "void (any, map)")
-        },
+        :all         => { x: PartitioningEpAllInclude::AllPanel.new() },
         :hd          => {
           :create => fun_ref(method(:CreateHdMainPanel), "void (any)"),
           :handle => fun_ref(method(:HandleHdMainPanel), "void (any, map)")
diff --git a/src/modules/TreePanel.rb b/src/modules/TreePanel.rb
index dea420e..935a9d1 100644
--- a/src/modules/TreePanel.rb
+++ b/src/modules/TreePanel.rb
@@ -45,20 +45,30 @@ module Yast
       @empty_panel = VBox(VStretch(), HStretch())
     end
 
+
+    class Panel < Client        # is Client the right class?
+
+      def create(user_data)
+      end
+
+      def refresh(user_data)
+      end
+
+      def handle(user_data, event)
+      end
+
+      def destroy(user_data)
+      end
+
+    end
+
+
     def CallCreate
       tmp = Ops.get(@data, @current_item)
-      create_func = Convert.convert(
-        Ops.get(tmp, :create),
-        :from => "any",
-        :to   => "void (any)"
-      )
-      if create_func != nil
       user_data = Ops.get(tmp, :user_data)
-        create_func.call(user_data)
+      tmp[:x].create(user_data)
     end
 
-      nil
-    end
 
     def CallRefresh
       tmp = Ops.get(@data, @current_item)

Reply via email to