small fix
[enigma2.git] / lib / python / Components / Pixmap.py
index 211b772c2be02edd02c9b348ea1b7c069e6f69f0..3fd09394dae09b01630625f171df0a61f02248d9 100644 (file)
@@ -1,21 +1,14 @@
-from ConditionalWidget import *
+from ConditionalWidget import ConditionalWidget
+from GUIComponent import GUIComponent
 
-from enigma import *
+from enigma import ePixmap, eTimer
 
-class Pixmap(Widget):
-       def __init__(self):
-               Widget.__init__(self)
-
-       def getePixmap(self, parent):
-               #pixmap = ePixmap(parent)
-               #pixmap.setPixmapFromFile(self.filename)
-               return ePixmap(parent)
-       
-       def createWidget(self, parent):
-               return self.getePixmap(parent)
+from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
+from os import path
+from skin import loadPixmap
 
-       def removeWidget(self, w):
-               pass
+class Pixmap(GUIComponent):
+       GUI_WIDGET = ePixmap
 
 class PixmapConditional(ConditionalWidget, Pixmap):
        def __init__(self, withTimer = True):
@@ -35,7 +28,7 @@ class MovingPixmap(Pixmap):
                self.clearPath()
                
                self.moveTimer = eTimer()
-               self.moveTimer.timeout.get().append(self.doMove)
+               self.moveTimer.callback.append(self.doMove)
                
        def clearPath(self, repeated = False):
                if (self.moving):
@@ -87,3 +80,36 @@ class MovingPixmap(Pixmap):
                        else:
                                self.moving = False
                                self.startMoving()
+
+class MultiPixmap(Pixmap):
+       def __init__(self):
+               Pixmap.__init__(self)
+               self.pixmaps = []
+
+       def applySkin(self, desktop, screen):
+               if self.skinAttributes is not None:
+                       skin_path_prefix = getattr(screen, "skin_path", path)
+                       pixmap = None
+                       attribs = [ ]
+                       for (attrib, value) in self.skinAttributes:
+                               if attrib == "pixmaps":
+                                       pixmaps = value.split(',')
+                                       for p in pixmaps:
+                                               self.pixmaps.append(loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, p, path_prefix=skin_path_prefix), desktop) )
+                                       if not pixmap:
+                                               pixmap = resolveFilename(SCOPE_SKIN_IMAGE, pixmaps[0], path_prefix=skin_path_prefix)
+                               elif attrib == "pixmap":
+                                       pixmap = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix)
+                               else:
+                                       attribs.append((attrib,value))
+                       if pixmap:
+                               attribs.append(("pixmap", pixmap))
+                       self.skinAttributes = attribs
+               return GUIComponent.applySkin(self, desktop, screen)
+
+       def setPixmapNum(self, x):
+               if self.instance:
+                       if len(self.pixmaps) > x:
+                               self.instance.setPixmap(self.pixmaps[x])
+                       else:
+                               print "setPixmapNum(%d) failed! defined pixmaps:" %(x), self.pixmaps