Re: [gDesklets] Control for Requesters (IInformer, IInformant, IInteraction, IRequester, ...??)



Hi again,

> Still to come:
> 
> - Stock icons for the buttons
> - free icons (gfx) for the main icon
> - alignment of the elements

OK, stock icons for the buttons are working.
But I am still fighting with python so that you can omit the icon if you
provide a stock-text, meaning:
[value1, stock-text, stock-icon] should be the same as [value1, stock-text]

The free icons have been keeping me busy the last hours. The main
problem is, that there seems to be no way to access the display's path
from within a Control. Although it shuold be there (maybe sometimes in
the future ?!) as in main/Control.py you can see in line 25/26:

        # the path of the display file (excluding the file)
        self.__display_path = ""

But unfortunately this never gets set to the display's path (AFAIS).
So I made a few changes to the core (see at the bottom) and in
test-control.py you can set and get the display's path, but - for what
reason ever - it is not working from within my test Control :/.
Anyway: I don't think that having the possibility to change the
display's path from outside of gDesklets is a good idea either....
If i provide a full path to the free icon everything works fine.

The aligment of the elements will be done after RC-1 is out ;).

So, if anyone has an idea how to set self.__display_path and how to
access it from within a Control... please let me know ;).

Greetings, Bjoern


----------
bzr diff
=== modified file 'factory/DisplayFactory.py'
--- factory/DisplayFactory.py	2010-01-07 02:40:31 +0000
+++ factory/DisplayFactory.py	2010-07-24 21:09:10 +0000
@@ -234,8 +234,8 @@
                 attrs["length"] = "0"
             length = int(attrs["length"])

-            script = "%s = get_control('%s', %d)" % \
-                     (ident, interface, length)
+            script = "%s = get_control('%s', %d, '%s')" % \
+                     (ident, interface, length, self.__path)
             self.__scripts.append((script, self.__filename))

         elif (state == _STATE_PREFS):

=== modified file 'main/Control.py'
--- main/Control.py	2007-06-23 12:09:42 +0000
+++ main/Control.py	2010-07-24 22:36:46 +0000
@@ -12,7 +12,7 @@
     # Warning : this is the only way to escape a Control
     # so be carefull when allowing a method to be called

-    AUTHORIZED_METHODS = ('bind', )
+    AUTHORIZED_METHODS = ('bind', 'get_display_path', )

     def __init__(self):

@@ -62,6 +62,20 @@
         gobject.source_remove(ident)


+    def get_display_path(self):
+
+        """ Returns the display's path. """
+
+        return self.__display_path
+
+
+    def _set_display_path(self, display_path):
+
+        """ Returns the display's path. """
+
+        self.__display_path = display_path
+
+
     def stop(self):

         """ Stops the control. """

=== modified file 'scripting/ControlWrapper.py'
--- scripting/ControlWrapper.py	2010-05-29 16:58:07 +0000
+++ scripting/ControlWrapper.py	2010-07-24 22:36:41 +0000
@@ -9,7 +9,7 @@
 #
 class ControlWrapper(object):

-    def __init__(self, control, size):
+    def __init__(self, control, size, display_path):

         self.__dict__["_ControlWrapper__length"] = size
         if size <= 0:
@@ -33,6 +33,7 @@
             # Initialize all initial copies
             for ctl in self.__dict__["_ControlWrapper__control"](open):
                 ctl.__init__()
+                ctl._set_display_path(display_path)

         # Keep an original copy around for extending the array
         self.__dict__["_ControlWrapper__original_control"] = Vault(control)

=== modified file 'scripting/Script.py'
--- scripting/Script.py	2010-06-20 19:52:22 +0000
+++ scripting/Script.py	2010-07-24 21:57:38 +0000
@@ -199,7 +199,7 @@
     #
     # Returns a control readily wrapped for the sandbox.
     #
-    def __script_get_control(self, interface, size):
+    def __script_get_control(self, interface, size, display_path):

         # FIXME: ensure that this does not break the sandbox
         from factory.ControlFactory import ControlFactory
@@ -207,7 +207,7 @@
         ctrl = factory.get_control(interface)
         if (ctrl):
             self.__loaded_controls.append(ctrl)
-            wrapped = ControlWrapper(ctrl, size)
+            wrapped = ControlWrapper(ctrl, size, display_path)
             return wrapped

         raise UserError(_("No Control could be found for interface %s") % \




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]