Merge branch 'master' into experimental
[enigma2.git] / lib / python / Components / ServiceList.py
index ced4b0c3372ff580ac9b34a1b440a9fb80a20dab..cd055a82335cc7bb28907a9eff9a3ca0893d9a10 100644 (file)
@@ -1,13 +1,13 @@
 from HTMLComponent import HTMLComponent
 from GUIComponent import GUIComponent
-from skin import parseColor
+from skin import parseColor, parseFont
 
 from enigma import eListboxServiceContent, eListbox, eServiceCenter, eServiceReference, gFont, eRect
 from Tools.LoadPixmap import LoadPixmap
 
-from string import upper
+from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN
 
-from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
+from Components.config import config
 
 class ServiceList(HTMLComponent, GUIComponent):
        MODE_NORMAL = 0
@@ -17,35 +17,39 @@ class ServiceList(HTMLComponent, GUIComponent):
                GUIComponent.__init__(self)
                self.l = eListboxServiceContent()
 
-               pic = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/folder.png"))
+               pic = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/folder.png"))
                if pic:
                        self.l.setPixmap(self.l.picFolder, pic)
 
-               pic = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/marker.png"))
+               pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/marker.png"))
                if pic:
                        self.l.setPixmap(self.l.picMarker, pic)
 
-               pic = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_s-fs8.png"))
+               pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_dvb_s-fs8.png"))
                if pic:
                        self.l.setPixmap(self.l.picDVB_S, pic)
 
-               pic = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_c-fs8.png"))
+               pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_dvb_c-fs8.png"))
                if pic:
                        self.l.setPixmap(self.l.picDVB_C, pic)
 
-               pic = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_t-fs8.png"))
+               pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_dvb_t-fs8.png"))
                if pic:
                        self.l.setPixmap(self.l.picDVB_T, pic)
 
-               pic = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_service_group-fs8.png"))
+               pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_service_group-fs8.png"))
                if pic:
                        self.l.setPixmap(self.l.picServiceGroup, pic)
 
                self.root = None
                self.mode = self.MODE_NORMAL
+               self.ItemHeight = 28
+               self.ServiceNameFont = parseFont("Regular;22", ((1,1),(1,1)))
+               self.ServiceInfoFont = parseFont("Regular;18", ((1,1),(1,1)))
+               self.ServiceNumberFont = parseFont("Regular;20", ((1,1),(1,1)))
                self.onSelectionChanged = [ ]
 
-       def applySkin(self, desktop):
+       def applySkin(self, desktop, parent):
                attribs = [ ]
                if self.skinAttributes is not None:
                        attribs = [ ]
@@ -60,10 +64,34 @@ class ServiceList(HTMLComponent, GUIComponent):
                                        self.l.setColor(eListboxServiceContent.markedBackgroundSelected, parseColor(value))
                                elif attrib == "foregroundColorServiceNotAvail":
                                        self.l.setColor(eListboxServiceContent.serviceNotAvail, parseColor(value))
+                               elif attrib == "colorEventProgressbar":
+                                       self.l.setColor(eListboxServiceContent.serviceEventProgressbarColor, parseColor(value))
+                               elif attrib == "colorEventProgressbarSelected":
+                                       self.l.setColor(eListboxServiceContent.serviceEventProgressbarColorSelected, parseColor(value))
+                               elif attrib == "colorEventProgressbarBorder":
+                                       self.l.setColor(eListboxServiceContent.serviceEventProgressbarBorderColor, parseColor(value))
+                               elif attrib == "colorEventProgressbarBorderSelected":
+                                       self.l.setColor(eListboxServiceContent.serviceEventProgressbarBorderColorSelected, parseColor(value))
+                               elif attrib == "colorServiceDescription":
+                                       self.l.setColor(eListboxServiceContent.serviceDescriptionColor, parseColor(value))
+                               elif attrib == "colorServiceDescriptionSelected":
+                                       self.l.setColor(eListboxServiceContent.serviceDescriptionColorSelected, parseColor(value))
+                               elif attrib == "picServiceEventProgressbar":
+                                       pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, value))
+                                       if pic:
+                                               self.l.setPixmap(self.l.picServiceEventProgressbar, pic)
+                               elif attrib == "serviceItemHeight":
+                                       self.ItemHeight = int(value)
+                               elif attrib == "serviceNameFont":
+                                       self.ServiceNameFont = parseFont(value, ((1,1),(1,1)))
+                               elif attrib == "serviceInfoFont":
+                                       self.ServiceInfoFont = parseFont(value, ((1,1),(1,1)))
+                               elif attrib == "serviceNumberFont":
+                                       self.ServiceNumberFont = parseFont(value, ((1,1),(1,1)))
                                else:
                                        attribs.append((attrib, value))
                self.skinAttributes = attribs
-               return GUIComponent.applySkin(self, desktop)
+               return GUIComponent.applySkin(self, desktop, parent)
 
        def connectSelChanged(self, fnc):
                if not fnc in self.onSelectionChanged:
@@ -101,7 +129,7 @@ class ServiceList(HTMLComponent, GUIComponent):
                # TODO fill with life
                print "Next char: "
                index = self.l.getNextBeginningWithChar(char)
-               indexup = self.l.getNextBeginningWithChar(upper(char))
+               indexup = self.l.getNextBeginningWithChar(char.upper())
                if indexup != 0:
                        if (index > indexup or index == 0):
                                index = indexup
@@ -203,18 +231,24 @@ class ServiceList(HTMLComponent, GUIComponent):
 
        def setMode(self, mode):
                self.mode = mode
-
+               self.l.setItemHeight(self.ItemHeight)
+               self.l.setVisualMode(eListboxServiceContent.visModeComplex)
                if mode == self.MODE_NORMAL:
-                       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.setElementFont(self.l.celServiceInfo, gFont("Regular", 18))
+                       if config.usage.show_event_progress_in_servicelist.value:
+                               self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(0, 0, 52, self.ItemHeight))
+                       else:
+                               self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(0, 0, 0, 0))
+                       self.l.setElementFont(self.l.celServiceName, self.ServiceNameFont)
+                       self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), self.ItemHeight))
+                       self.l.setElementFont(self.l.celServiceInfo, self.ServiceInfoFont)
                else:
-                       self.l.setItemHeight(28)
-                       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))
+                       if config.usage.show_event_progress_in_servicelist.value:
+                               self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(60, 0, 52, self.ItemHeight))
+                       else:
+                               self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(60, 0, 0, 0))
+                       self.l.setElementFont(self.l.celServiceNumber, self.ServiceNumberFont)
+                       self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 50, self.ItemHeight))
+                       self.l.setElementFont(self.l.celServiceName, self.ServiceNameFont)
+                       self.l.setElementPosition(self.l.celServiceName, eRect(60, 0, self.instance.size().width()-60, self.ItemHeight))
+                       self.l.setElementFont(self.l.celServiceInfo, self.ServiceInfoFont)
+