dont send a diseqc switch command when simple rotor mode is used
[enigma2.git] / lib / python / Components / ServiceList.py
index 89b40ed2260eaa48bcaaaad8f35992a819f1fb18..7dfcd05d51c700de02efa76d8a929e29d3eb8ef9 100644 (file)
@@ -1,18 +1,41 @@
 from HTMLComponent import *
 from GUIComponent import *
 
 from HTMLComponent import *
 from GUIComponent import *
 
-from enigma import *
+from enigma import loadPNG, eListboxServiceContent, eListbox, eServiceCenter, eServiceReference, gFont, eRect
 
 
-class ServiceList(HTMLComponent, GUIComponent):
+from string import upper
+
+from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS
 
 
+class ServiceList(HTMLComponent, GUIComponent):
        MODE_NORMAL = 0
        MODE_FAVOURITES = 1
 
        def __init__(self):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
        MODE_NORMAL = 0
        MODE_FAVOURITES = 1
 
        def __init__(self):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "folder.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picFolder, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "marker-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picMarker, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_s-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picDVB_S, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_c-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picDVB_C, pic)
+
+               pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_t-fs8.png"))
+               if pic:
+                       self.l.setPixmap(self.l.picDVB_T, pic)
+
                self.root = None
                self.root = None
-               
                self.mode = self.MODE_NORMAL
 
        def setCurrent(self, ref):
                self.mode = self.MODE_NORMAL
 
        def setCurrent(self, ref):
@@ -23,19 +46,50 @@ class ServiceList(HTMLComponent, GUIComponent):
                self.l.getCurrent(r)
                return r
 
                self.l.getCurrent(r)
                return r
 
+       def atBegin(self):
+               return self.instance.atBegin()
+
+       def atEnd(self):
+               return self.instance.atEnd()
+
        def moveUp(self):
                self.instance.moveSelection(self.instance.moveUp)
 
        def moveDown(self):
                self.instance.moveSelection(self.instance.moveDown)
 
        def moveUp(self):
                self.instance.moveSelection(self.instance.moveUp)
 
        def moveDown(self):
                self.instance.moveSelection(self.instance.moveDown)
 
-       def GUIcreate(self, parent):
-               self.instance = eListbox(parent)
-               self.instance.setContent(self.l)
-               self.setMode(self.mode)
+       def moveToChar(self, char):
+               # TODO fill with life
+               print "Next char: "
+               index = self.l.getNextBeginningWithChar(char)
+               indexup = self.l.getNextBeginningWithChar(upper(char))
+               if indexup != 0:
+                       if (index > indexup or index == 0):
+                               index = indexup
+
+               self.instance.moveSelectionTo(index)
+               print "Moving to character " + str(char)
+
+       def moveToNextMarker(self):
+               idx = self.l.getNextMarkerPos()
+               self.instance.moveSelectionTo(idx)
+
+       def moveToPrevMarker(self):
+               idx = self.l.getPrevMarkerPos()
+               self.instance.moveSelectionTo(idx)
+
+       def moveToIndex(self, index):
+               self.instance.moveSelectionTo(index)
+
+       def getCurrentIndex(self):
+               return self.instance.getCurrentIndex()
+
+       GUI_WIDGET = eListbox
        
        
-       def GUIdelete(self):
-               self.instance = None
+       def postWidgetCreate(self, instance):
+               instance.setWrapAround(True)
+               instance.setContent(self.l)
+               self.setMode(self.mode)
 
        def getRoot(self):
                return self.root
 
        def getRoot(self):
                return self.root
@@ -56,9 +110,23 @@ class ServiceList(HTMLComponent, GUIComponent):
        def setNumberOffset(self, offset):
                self.l.setNumberOffset(offset)
 
        def setNumberOffset(self, offset):
                self.l.setNumberOffset(offset)
 
-       def setRoot(self, root):
+       def setPlayableIgnoreService(self, ref):
+               self.l.setIgnoreService(ref)
+
+       def setRoot(self, root, justSet=False):
                self.root = root
                self.root = root
-               self.l.setRoot(root)
+               self.l.setRoot(root, justSet)
+               if not justSet:
+                       self.l.sort()
+
+       def removeCurrent(self):
+               self.l.removeCurrent()
+
+       def addService(self, service, beforeCurrent=False):
+               self.l.addService(service, beforeCurrent)
+
+       def finishFill(self):
+               self.l.FillFinished()
                self.l.sort()
 
 # stuff for multiple marks (edit mode / later multiepg)
                self.l.sort()
 
 # stuff for multiple marks (edit mode / later multiepg)
@@ -91,21 +159,17 @@ class ServiceList(HTMLComponent, GUIComponent):
        def setMode(self, mode):
                self.mode = mode
 
        def setMode(self, mode):
                self.mode = mode
 
-               try:
-                       self.instance
-               except:
-                       return
-               
                if mode == self.MODE_NORMAL:
                if mode == self.MODE_NORMAL:
-                       self.instance.setItemHeight(28)
-                       self.l.setVisualMode(eListboxServiceContent.visModeSimple)
-                       self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
+                       self.l.setItemHeight(28)
+                       self.l.setVisualMode(eListboxServiceContent.visModeComplex)
+                       self.l.setElementFont(self.l.celServiceName, gFont("Regular", 22))
                        self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), 28))
                        self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), 28))
+                       self.l.setElementFont(self.l.celServiceInfo, gFont("Regular", 18))
                else:
                else:
-                       self.instance.setItemHeight(28)
-                       self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20))
-                       self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 40, 28))
-                       self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
-                       self.l.setElementPosition(self.l.celServiceName, eRect(50, 0, self.instance.size().width()-50, 28))
-                       self.l.setElementFont(self.l.celServiceInfo, gFont("Arial", 18))
+                       self.l.setItemHeight(28)
                        self.l.setVisualMode(eListboxServiceContent.visModeComplex)
                        self.l.setVisualMode(eListboxServiceContent.visModeComplex)
+                       self.l.setElementFont(self.l.celServiceNumber, gFont("Regular", 20))
+                       self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 50, 28))
+                       self.l.setElementFont(self.l.celServiceName, gFont("Regular", 22))
+                       self.l.setElementPosition(self.l.celServiceName, eRect(60, 0, self.instance.size().width()-60, 28))
+                       self.l.setElementFont(self.l.celServiceInfo, gFont("Regular", 18))