fix frequently vacancies in multiepg
[enigma2.git] / lib / python / Plugins / Extensions / GraphMultiEPG / GraphMultiEpg.py
index 45a5139bce6cb18cade5630e05ffd39d39edd11c..bf8323151d3fac28208a0a3fa5f1e4e00e1aed6c 100644 (file)
@@ -49,6 +49,8 @@ class EPGList(HTMLComponent, GUIComponent):
                self.borderColor = None
                self.backColor = 0x586d88
                self.backColorSelected = 0x808080
+               self.foreColorService = None
+               self.backColorService = None
 
        def applySkin(self, desktop):
                if self.skinAttributes is not None:
@@ -64,6 +66,10 @@ class EPGList(HTMLComponent, GUIComponent):
                                        self.backColor = parseColor(value).argb()
                                elif attrib == "EntryBackgroundColorSelected":
                                        self.backColorSelected = parseColor(value).argb()
+                               elif attrib == "ServiceNameForegroundColor":
+                                       self.foreColorService = parseColor(value).argb()
+                               elif attrib == "ServiceNameBackgroundColor":
+                                       self.backColorService = parseColor(value).argb()
                                else:
                                        attribs.append((attrib,value))
                        self.skinAttributes = attribs
@@ -192,7 +198,7 @@ class EPGList(HTMLComponent, GUIComponent):
        def buildEntry(self, service, service_name, events):
                r1=self.service_rect
                r2=self.event_rect
-               res = [ None, MultiContentEntryText(pos = (r1.left(),r1.top()), size = (r1.width(), r1.height()), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_CENTER, text = service_name) ]
+               res = [ None, MultiContentEntryText(pos = (r1.left(),r1.top()), size = (r1.width(), r1.height()), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_CENTER, text = service_name, color = self.foreColorService, backcolor = self.backColorService) ]
 
                if events:
                        start = self.time_base+self.offs*self.time_epoch*60
@@ -219,25 +225,27 @@ class EPGList(HTMLComponent, GUIComponent):
                cur_service = self.cur_service #(service, service_name, events)
                if not self.event_rect:
                        self.recalcEntrySize()
-               if cur_service and self.cur_event is not None:
+               valid_event = self.cur_event is not None
+               if cur_service:
                        update = True
                        entries = cur_service[2]
                        if dir == 0: #current
                                update = False
                        elif dir == +1: #next
-                               if self.cur_event+1 < len(entries):
+                               if valid_event and self.cur_event+1 < len(entries):
                                        self.cur_event+=1
                                else:
                                        self.offs += 1
                                        self.fillMultiEPG(None) # refill
                                        return True
                        elif dir == -1: #prev
-                               if self.cur_event-1 >= 0:
+                               if valid_event and self.cur_event-1 >= 0:
                                        self.cur_event-=1
                                elif self.offs > 0:
                                        self.offs -= 1
                                        self.fillMultiEPG(None) # refill
                                        return True
+               if cur_service and valid_event:
                        entry = entries[self.cur_event] #(event_id, event_title, begin_time, duration)
                        time_base = self.time_base+self.offs*self.time_epoch*60
                        xpos, width = self.calcEntryPosAndWidth(self.event_rect, time_base, self.time_epoch, entry[2], entry[3])
@@ -274,13 +282,13 @@ class EPGList(HTMLComponent, GUIComponent):
                for x in epg_data:
                        if service != x[0]:
                                if tmp_list is not None:
-                                       self.list.append((service, sname, tmp_list[0][0] and tmp_list))
+                                       self.list.append((service, sname, tmp_list[0][0] is not None and tmp_list or None))
                                service = x[0]
                                sname = x[1]
                                tmp_list = [ ]
                        tmp_list.append((x[2], x[3], x[4], x[5]))
                if tmp_list and len(tmp_list):
-                       self.list.append((service, sname, tmp_list[0][0] and tmp_list))
+                       self.list.append((service, sname, tmp_list[0][0] is not None and tmp_list or None))
 
                self.l.setList(self.list)
                self.findBestEvent()