X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/8f80c7c5867d6eddde43a612b25e67b6435e44b4..6b3ca84eed5260ec5d8877669e565ee82153b428:/lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py diff --git a/lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py b/lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py index 9040539a..036cb7a6 100644 --- a/lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py +++ b/lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py @@ -7,7 +7,7 @@ from Components.HTMLComponent import HTMLComponent from Components.GUIComponent import GUIComponent from Components.EpgList import Rect from Components.Sources.Event import Event -from Components.Sources.Source import ObsoleteSource +from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest from Screens.Screen import Screen from Screens.EventView import EventViewSimple from Screens.TimeDateInput import TimeDateInput @@ -16,7 +16,8 @@ from Screens.EpgSelection import EPGSelection from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE from RecordTimer import RecordTimerEntry, parseEvent from ServiceReference import ServiceReference -from enigma import eEPGCache, eListbox, eListboxPythonMultiContent, gFont, loadPNG, \ +from Tools.LoadPixmap import LoadPixmap +from enigma import eEPGCache, eListbox, gFont, eListboxPythonMultiContent, \ RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, eRect, eTimer from time import localtime, time, strftime @@ -37,33 +38,42 @@ class EPGList(HTMLComponent, GUIComponent): if overjump_empty: self.l.setSelectableFunc(self.isSelectable) self.epgcache = eEPGCache.getInstance() - self.clock_pixmap = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, 'epgclock-fs8.png')) + self.clock_pixmap = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/epgclock.png')) self.time_base = None self.time_epoch = time_epoch self.list = None self.event_rect = None self.foreColor = None + self.foreColorSelected = None self.borderColor = None self.backColor = 0x586d88 self.backColorSelected = 0x808080 + self.foreColorService = None + self.backColorService = None - def applySkin(self, desktop): + def applySkin(self, desktop, screen): if self.skinAttributes is not None: attribs = [ ] for (attrib, value) in self.skinAttributes: if attrib == "EntryForegroundColor": self.foreColor = parseColor(value).argb() + elif attrib == "EntryForegroundColorSelected": + self.foreColorSelected = parseColor(value).argb() elif attrib == "EntryBorderColor": self.borderColor = parseColor(value).argb() elif attrib == "EntryBackgroundColor": 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 - return GUIComponent.applySkin(self, desktop) + return GUIComponent.applySkin(self, desktop, screen) def isSelectable(self, service, sname, event_list): return (event_list and len(event_list) and True) or False @@ -110,10 +120,13 @@ class EPGList(HTMLComponent, GUIComponent): old_service = self.cur_service #(service, service_name, events) cur_service = self.cur_service = self.l.getCurrentSelection() last_time = 0; + time_base = self.getTimeBase() if old_service and self.cur_event is not None: events = old_service[2] cur_event = events[self.cur_event] #(event_id, event_title, begin_time, duration) last_time = cur_event[2] + if last_time < time_base: + last_time = time_base if cur_service: self.cur_event = 0 events = cur_service[2] @@ -123,7 +136,10 @@ class EPGList(HTMLComponent, GUIComponent): best = len(events) #set invalid idx = 0 for event in events: #iterate all events - diff = abs(event[2]-last_time) + ev_time = event[2] + if ev_time < time_base: + ev_time = time_base + diff = abs(ev_time-last_time) if (best == len(events)) or (diff < best_diff): best = idx best_diff = diff @@ -149,11 +165,16 @@ class EPGList(HTMLComponent, GUIComponent): instance.setWrapAround(True) instance.selectionChanged.get().append(self.serviceChanged) instance.setContent(self.l) + self.l.setFont(0, gFont("Regular", 20)) + self.l.setFont(1, gFont("Regular", 14)) + self.l.setSelectionClip(eRect(0,0,0,0), False) + + def preWidgetRemove(self, instance): + instance.selectionChanged.get().remove(self.serviceChanged) + instance.setContent(None) def recalcEntrySize(self): esize = self.l.getItemSize() - self.l.setFont(0, gFont("Regular", 20)) - self.l.setFont(1, gFont("Regular", 14)) width = esize.width() height = esize.height() xpos = 0; @@ -162,7 +183,6 @@ class EPGList(HTMLComponent, GUIComponent): xpos += w; w = width/10*8; self.event_rect = Rect(xpos, 0, w, height) - self.l.setSelectionClip(eRect(0,0,0,0), False) def calcEntryPosAndWidthHelper(self, stime, duration, start, end, width): xpos = (stime - start) * width / (end - start) @@ -182,8 +202,7 @@ class EPGList(HTMLComponent, GUIComponent): def buildEntry(self, service, service_name, events): r1=self.service_rect r2=self.event_rect - res = [ None ] # no private data needed - res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, 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 @@ -193,44 +212,43 @@ class EPGList(HTMLComponent, GUIComponent): width = r2.width() height = r2.height() foreColor = self.foreColor + foreColorSelected = self.foreColorSelected backColor = self.backColor backColorSelected = self.backColorSelected borderColor = self.borderColor for ev in events: #(event_id, event_title, begin_time, duration) - rec=self.timer.isInTimer(ev[0], ev[2], ev[3], service) > ((ev[3]/10)*8) + rec=ev[2] and self.timer.isInTimer(ev[0], ev[2], ev[3], service) > ((ev[3]/10)*8) xpos, ewidth = self.calcEntryPosAndWidthHelper(ev[2], ev[3], start, end, width) - if self.borderColor is None: - res.append((eListboxPythonMultiContent.TYPE_TEXT, left+xpos, top, ewidth, height, 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, ev[1], foreColor, backColor, backColorSelected, 1)) - else: - res.append((eListboxPythonMultiContent.TYPE_TEXT, left+xpos, top, ewidth, height, 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, ev[1], foreColor, backColor, backColorSelected, 1, borderColor)) + res.append(MultiContentEntryText(pos = (left+xpos, top), size = (ewidth, height), font = 1, flags = RT_HALIGN_CENTER | RT_VALIGN_CENTER | RT_WRAP, text = ev[1], color = foreColor, color_sel = foreColorSelected, backcolor = backColor, backcolor_sel = backColorSelected, border_width = 1, border_color = borderColor)) if rec and ewidth > 23: - res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, left+xpos+ewidth-22, top+height-22, 21, 21, self.clock_pixmap, backColor, backColorSelected)) + res.append(MultiContentEntryPixmapAlphaTest(pos = (left+xpos+ewidth-22, top+height-22), size = (21, 21), png = self.clock_pixmap, backcolor = backColor, backcolor_sel = backColorSelected)) return res def selEntry(self, dir, visible=True): 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: + self.recalcEntrySize() + 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]) @@ -257,7 +275,7 @@ class EPGList(HTMLComponent, GUIComponent): self.cur_service = None self.time_base = int(stime) test = [ (service.ref.toString(), 0, self.time_base, self.time_epoch) for service in services ] - test.insert(0, 'RnITBD') + test.insert(0, 'XRnITBD') epg_data = self.queryEPG(test) self.list = [ ] @@ -267,13 +285,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() @@ -328,7 +346,6 @@ class GraphMultiEPG(Screen): self["key_green"] = Button(_("Add timer")) self["timeline_text"] = TimelineText() self["Event"] = Event() - self["Clock"] = ObsoleteSource(new_source = "global.CurrentTime", removal_date = "2008-01") self.time_lines = [ ] for x in (0,1,2,3,4,5): pm = Pixmap() @@ -365,7 +382,7 @@ class GraphMultiEPG(Screen): },-1) self.updateTimelineTimer = eTimer() - self.updateTimelineTimer.timeout.get().append(self.moveTimeLines) + self.updateTimelineTimer.callback.append(self.moveTimeLines) self.updateTimelineTimer.start(60*1000) self.onLayoutFinish.append(self.onCreate) @@ -481,7 +498,7 @@ class GraphMultiEPG(Screen): serviceref = cur[1] if event is None: return - newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event)) + newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, dirname = config.movielist.last_timer_videodir.value, *parseEvent(event)) self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry) def timerEditFinished(self, answer):